1 // File: BRepFeat_MakeRevolutionForm.cxx
2 // Created: Tue Oct 14 16:15:49 1997
3 // Author: Olga KOULECHOVA
4 // <opt@cleox.paris1.matra-dtv.fr>
7 #include <BRepFeat_MakeRevolutionForm.ixx>
9 #include <BRepFeat.hxx>
12 #include <LocOpe_Builder.hxx>
13 #include <LocOpe_RevolutionForm.hxx>
14 #include <LocOpe_CSIntersector.hxx>
15 #include <LocOpe_PntFace.hxx>
16 #include <LocOpe_Gluer.hxx>
17 #include <LocOpe_FindEdges.hxx>
25 #include <gp_Vec2d.hxx>
26 #include <gp_Pnt2d.hxx>
28 #include <Geom_Curve.hxx>
30 #include <Geom2d_Curve.hxx>
31 #include <Geom2d_Line.hxx>
33 #include <Geom_Line.hxx>
34 #include <Geom_Circle.hxx>
35 #include <Geom_Plane.hxx>
36 #include <Geom_Surface.hxx>
37 #include <Geom_CylindricalSurface.hxx>
38 #include <Geom_ConicalSurface.hxx>
39 #include <Geom_ToroidalSurface.hxx>
40 #include <Geom_RectangularTrimmedSurface.hxx>
42 #include <Geom_TrimmedCurve.hxx>
43 #include <GeomProjLib.hxx>
45 #include <Geom2dAPI_InterCurveCurve.hxx>
46 #include <Geom2dAPI_ExtremaCurveCurve.hxx>
47 #include <Geom2d_Curve.hxx>
48 #include <Geom2d_Curve.hxx>
51 #include <GeomAPI.hxx>
52 #include <GeomAPI_ProjectPointOnCurve.hxx>
54 #include <TColgp_SequenceOfPnt.hxx>
56 #include <TColGeom_SequenceOfCurve.hxx>
58 #include <TColStd_Array1OfReal.hxx>
59 #include <IntRes2d_IntersectionPoint.hxx>
61 #include <BRepTools_WireExplorer.hxx>
63 #include <BRep_Tool.hxx>
64 #include <BRep_Builder.hxx>
66 #include <TopExp_Explorer.hxx>
69 #include <TopTools_MapOfShape.hxx>
70 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
71 #include <TopTools_ListOfShape.hxx>
72 #include <TopTools_ListIteratorOfListOfShape.hxx>
73 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
74 #include <TopTools_MapIteratorOfMapOfShape.hxx>
75 #include <TopOpeBRepBuild_HBuilder.hxx>
76 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
78 #include <TColgp_Array1OfPnt.hxx>
80 #include <TColGeom_Array1OfCurve.hxx>
83 #include <TopoDS_Shape.hxx>
84 #include <TopoDS_Face.hxx>
86 #include <BRepLib_MakeVertex.hxx>
87 #include <BRepLib_MakeEdge.hxx>
88 #include <BRepLib_MakeFace.hxx>
90 #include <BRepTools.hxx>
92 #include <BRepPrimAPI_MakeBox.hxx>
93 #include <BRepBuilderAPI_MakeFace.hxx>
95 #include <BRepAlgo.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 #include <BRepAlgoAPI_Cut.hxx>
102 #include <BRepAlgoAPI_Section.hxx>
103 #include <BRepAlgoAPI_Common.hxx>
104 //modified by NIZNHY-PKV Fri Mar 22 16:56:17 2002 t
106 #include <BRepBuilderAPI_Transform.hxx>
107 #include <BRepExtrema_ExtPC.hxx>
108 #include <BRepExtrema_ExtCF.hxx>
110 #include <BRepTools_Modifier.hxx>
111 #include <BRepTools_TrsfModification.hxx>
113 #include <BRepTopAdaptor_FClass2d.hxx>
115 #include <Standard_ConstructionError.hxx>
117 #include <Precision.hxx>
120 #include <ElCLib.hxx>
121 #include <ElSLib.hxx>
124 #include <GeomLProp_CLProps.hxx>
127 Standard_IMPORT Standard_Boolean BRepFeat_GettraceFEAT();
128 Standard_IMPORT Standard_Boolean BRepFeat_GettraceFEATRIB();
131 static void MajMap(const TopoDS_Shape&, // base
132 const LocOpe_RevolutionForm&,
133 TopTools_DataMapOfShapeListOfShape&, // myMap
134 TopoDS_Shape&, // myFShape
135 TopoDS_Shape&); // myLShape
137 static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
138 LocOpe_RevolutionForm&,
139 const TopTools_DataMapOfShapeListOfShape& SlidingMap,
140 TopTools_DataMapOfShapeShape&);
142 //=======================================================================
145 //=======================================================================
147 void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
148 const TopoDS_Wire& W,
149 const Handle(Geom_Plane)& Plane,
151 const Standard_Real H1,
152 const Standard_Real H2,
153 const Standard_Integer Mode,
154 Standard_Boolean& Modify)
157 Standard_Boolean trc = BRepFeat_GettraceFEAT();
158 if (trc) cout << "BRepFeat_MakeRevolutionForm::Init" << endl;
160 Standard_Boolean RevolRib = Standard_True;
163 // modify = 0 si on ne veut pas faire de glissement
164 // = 1 si on veut essayer de faire un glissement
165 Standard_Boolean Sliding = Modify;
168 Handle(Geom_Line) Line = new Geom_Line(Axis);
169 Standard_Real LineFirst, LineLast;
171 LocOpe_CSIntersector ASI(Sbase);
172 TColGeom_SequenceOfCurve scur;
176 if(ASI.IsDone() && ASI.NbPoints(1) >= 2) {
177 LineLast = ASI.Point(1, ASI.NbPoints(1)).Parameter();
178 LineFirst = ASI.Point(1, 1).Parameter();
181 LineFirst = RealFirst();
182 LineLast = RealLast();
185 Handle(Geom2d_Curve) ln2d = GeomAPI::To2d(Line, Plane->Pln());
188 Standard_Real Rad = RealLast();
190 exx.Init(W, TopAbs_EDGE);
191 for(; exx.More(); exx.Next()) {
192 const TopoDS_Edge& e = TopoDS::Edge(exx.Current());
194 Handle(Geom_Curve) c = BRep_Tool::Curve(e, f, l);
195 Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, Plane->Pln());
196 Geom2dAPI_ExtremaCurveCurve extr(ln2d, c2d, LineFirst, LineLast,f,l);
197 Quantity_Length L = RealLast();
198 if(extr.NbExtrema() >= 1) {
199 L = extr.LowerDistance();
201 gp_Pnt p1 = c->Value(f);
202 gp_Pnt p2 = c->Value(l);
203 GeomAPI_ProjectPointOnCurve proj1(p1, Line);
204 GeomAPI_ProjectPointOnCurve proj2(p2, Line);
205 if(proj1.NbPoints() < 1 || proj2.NbPoints() < 1) {
207 if (trc) cout << " No projection points" << endl;
209 myStatusError = BRepFeat_NoProjPt;
213 Standard_Real par1 = proj1.Distance(1);
214 Standard_Real par2 = proj2.Distance(1);
215 Standard_Real Par = Min(par1, par2);
217 if(L<Rad && L > 0.) Rad = L;
220 Standard_Real height = Min(H1, H2);
222 if(Rad <= height) Rad = height + 0.01*height;
224 myAngle1 = asin(H1/Rad) + PI/10.;
225 myAngle2 = asin(H2/Rad) + PI/10.;
227 if((myAngle1 - PI/2) > Precision::Confusion())
229 if((myAngle2 - PI/2) > Precision::Confusion())
236 myFuse = Standard_False;
237 else // if(Mode == 1)
238 myFuse = Standard_True;
241 if (myFuse) cout << " Fuse" << endl;
242 if (!myFuse) cout << " Cut" << endl;
246 // ---Determination Tolerance : tolerance max sur les parametres
247 myTol = Precision::Confusion();
249 exx.Init(W, TopAbs_VERTEX);
250 for(; exx.More(); exx.Next()) {
251 const Standard_Real& tol = BRep_Tool::
252 Tolerance(TopoDS::Vertex(exx.Current()));
253 if(tol > myTol) myTol = tol;
256 exx.Init(Sbase, TopAbs_VERTEX);
257 for(; exx.More(); exx.Next()) {
258 const Standard_Real& tol = BRep_Tool::
259 Tolerance(TopoDS::Vertex(exx.Current()));
260 if(tol > myTol) myTol = tol;
263 TopoDS_Shape aLocalShape = W.Oriented(TopAbs_FORWARD);
264 myWire = TopoDS::Wire(aLocalShape);
265 // myWire = TopoDS::Wire(W.Oriented(TopAbs_FORWARD));
277 // ---Calcul boite englobante
280 TopTools_ListOfShape theList;
284 gp_Pnt FirstCorner, LastCorner;
285 Standard_Real bnd = HeightMax(mySbase, U, FirstCorner, LastCorner);
288 BRepPrimAPI_MakeBox Bndbox(FirstCorner, LastCorner);
289 TopoDS_Solid BndBox = Bndbox.Solid();
292 // ---Construction de la face plan de travail (section boite englobante)
293 BRepLib_MakeFace PlaneF(myPln->Pln(), -6.*myBnd,
294 6.*myBnd, -6.*myBnd, 6.*myBnd);
295 TopoDS_Face PlaneFace = TopoDS::Face(PlaneF.Shape());
297 //modified by NIZNHY-PKV Fri Mar 22 16:52:26 2002 f
298 //BRepAlgo_Common PlaneS(BndBox, PlaneFace);
299 BRepAlgoAPI_Common PlaneS(BndBox, PlaneFace);
300 //modified by NIZNHY-PKV Fri Mar 22 16:52:31 2002 t
302 TopoDS_Shape PlaneSect = PlaneS.Shape();
303 EXP.Init(PlaneSect, TopAbs_WIRE);
304 TopoDS_Wire www = TopoDS::Wire(EXP.Current());
305 BRepLib_MakeFace Bndface(myPln->Pln(), www, Standard_True);
306 TopoDS_Face BndFace = TopoDS::Face(Bndface.Shape());
309 // ---Recherche des faces d'appui de la nervure
310 TopoDS_Edge FirstEdge, LastEdge;
311 TopoDS_Face FirstFace, LastFace;
312 TopoDS_Vertex FirstVertex, LastVertex;
314 Standard_Boolean OnFirstFace = Standard_False;
315 Standard_Boolean OnLastFace = Standard_False;
316 Standard_Boolean PtOnFirstEdge = Standard_False;
317 Standard_Boolean PtOnLastEdge = Standard_False;
318 TopoDS_Edge OnFirstEdge, OnLastEdge;
319 OnFirstEdge.Nullify();
320 OnLastEdge.Nullify();
322 Standard_Boolean Data = ExtremeFaces(RevolRib, myBnd, myPln, FirstEdge, LastEdge,
323 FirstFace, LastFace, FirstVertex,
324 LastVertex, OnFirstFace, OnLastFace,
325 PtOnFirstEdge, PtOnLastEdge,
326 OnFirstEdge, OnLastEdge);
330 if (trc) cout << " No Extreme faces" << endl;
332 myStatusError = BRepFeat_NoExtFace;
338 // ---Point detrompeur pour le cote du wire a remplir - cote matiere
339 gp_Pnt CheckPnt = CheckPoint(FirstEdge, bnd/10., myPln);
341 // Standard_Real f, l;
343 // ---Controle glissement valable
344 // Plein de cas ou on sort du glissement
345 Standard_Integer Concavite = 3; // a priori le profile n'est pas concave
347 myFirstPnt = BRep_Tool::Pnt(FirstVertex);
348 myLastPnt = BRep_Tool::Pnt(LastVertex);
350 // SliList : liste des faces concernees par la nervure
351 TopTools_ListOfShape SliList;
352 SliList.Append(FirstFace);
354 if(Sliding) { // glissement
356 if (trc) cout << " Sliding" << endl;
358 Handle(Geom_Surface) s = BRep_Tool::Surface(FirstFace);
359 if (s->DynamicType() ==
360 STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
361 s = Handle(Geom_RectangularTrimmedSurface)::
362 DownCast(s)->BasisSurface();
364 if(s->DynamicType() != STANDARD_TYPE(Geom_Plane) &&
365 s->DynamicType() != STANDARD_TYPE(Geom_CylindricalSurface) &&
366 s->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface) &&
367 s->DynamicType() != STANDARD_TYPE(Geom_ToroidalSurface))
368 Sliding = Standard_False;
371 if(Sliding) { // glissement
372 Handle(Geom_Surface) ss = BRep_Tool::Surface(LastFace);
373 if (ss->DynamicType() ==
374 STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
375 ss = Handle(Geom_RectangularTrimmedSurface)::
376 DownCast(ss)->BasisSurface();
378 if(ss->DynamicType() != STANDARD_TYPE(Geom_Plane) &&
379 ss->DynamicType() != STANDARD_TYPE(Geom_CylindricalSurface) &&
380 ss->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface) &&
381 ss->DynamicType() != STANDARD_TYPE(Geom_ToroidalSurface))
382 Sliding = Standard_False;
385 // Controle uniquement points de depart et d'arrivee
386 // -> pas de controle au milieu - a ameliorer
387 // Si on faisait un controle entre Surface et sgement entre les 2 points limite
388 // -> tres cher - a ameliorer
389 //gp_Pnt FirstCenter, LastCenter;
390 gp_Circ FirstCircle, LastCircle;
391 Handle(Geom_Curve) FirstCrv, LastCrv;
393 if(Sliding) { // glissement
394 GeomAPI_ProjectPointOnCurve proj(myFirstPnt, Line);
395 if(proj.NbPoints() < 1) {
397 if (trc) cout << " No First Point projection" << endl;
399 myStatusError = BRepFeat_NoProjPt;
403 Standard_Real FirstRayon = proj.Distance(1);
404 gp_Pnt FirstCenter = proj.Point(1);
406 GeomAPI_ProjectPointOnCurve proj1(myLastPnt, Line);
407 if(proj.NbPoints() < 1) {
409 if (trc) cout << " No Last Point projection" << endl;
411 myStatusError = BRepFeat_NoProjPt;
415 Standard_Real LastRayon = proj1.Distance(1);
416 gp_Pnt LastCenter = proj1.Point(1);
418 gp_Vec axv(myAxe.Direction());
419 gp_Ax2 ax2(FirstCenter, axv);
420 gp_Ax2 ax2p(LastCenter, axv);
421 gp_Circ theFC(ax2, FirstRayon);
422 gp_Circ theLC(ax2p, LastRayon);
424 gp_Pnt RFirstPnt1 = myFirstPnt.Rotated(myAxe, myAngle1);
425 gp_Pnt RLastPnt1 = myLastPnt.Rotated(myAxe, myAngle1);
426 gp_Pnt RFirstPnt2 = myFirstPnt.Rotated(myAxe, -myAngle2);
427 gp_Pnt RLastPnt2 = myLastPnt.Rotated(myAxe, -myAngle2);
430 TopoDS_Vertex v1, v2, v3, v4;
431 Bu.MakeVertex(v1, RFirstPnt2, Precision::Confusion());
432 Bu.MakeVertex(v2, RFirstPnt1, Precision::Confusion());
433 Bu.MakeVertex(v3, RLastPnt2, Precision::Confusion());
434 Bu.MakeVertex(v4, RLastPnt1, Precision::Confusion());
436 BRepLib_MakeEdge ee1(theFC, v1, v2);
437 BRepLib_MakeEdge ee2(theLC, v3, v4);
439 if(Sliding && !PtOnFirstEdge) {
440 BRepExtrema_ExtCF ext1(TopoDS::Edge(ee1.Shape()), FirstFace);
442 Standard_Integer nb =
448 ext1.SquareDistance(1);
449 if(ext1.NbExt() < 1 || ext1.SquareDistance(1) > Precision::Confusion() * Precision::Confusion())
450 Sliding = Standard_False;
452 if(Sliding && !PtOnLastEdge) {
453 BRepExtrema_ExtCF ext2(ee2, LastFace); // ExtCF : courbes et surfaces
454 if(ext2.NbExt() < 1 || ext2.SquareDistance(1) > Precision::Confusion() * Precision::Confusion())
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 // On construit un gros profil qui va jusqu`a la boite englobante
511 // -> par tangence avec premier et dernier edge du Wire
512 // -> par normales aux faces d'appui : statistiquement meilleur
513 // On intersecte le tout pour trouver le profil final
516 // ---cas de glissement : construction de la face profil
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 sur les faces du shape initial
539 // pour trouver les faces concernees par la nervure
540 Standard_Boolean falseside = Standard_True;
541 Sliding = Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
542 // Controle si on a ce qu`il faut pour avoir la matiere du bon cote
543 if(falseside == Standard_False) {
545 cout << " Verify plane and wire orientation" << endl;
547 myStatusError = BRepFeat_FalseSide;
554 // ---Generation du profile de base de la nervure
558 TopoDS_Edge thePreviousEdge;
560 thePreviousEdge.Nullify();
562 // compteur du nombre d`edges pour remplir la map
563 Standard_Integer counter = 1;
565 // ---cas de glissement
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 // Cas plusieurs 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);
759 Standard_Real dist1 =
761 theLastPnt.Distance(myLastPnt);
764 theLastPnt = BRep_Tool::Pnt(TopExp::LastVertex(theEdge,Standard_True));
770 else if(FirstFlag == 2) {
775 it.Initialize(myListOfEdges);
776 LastOK = Standard_False;
778 else if(it.More()) it.Next();
780 Sliding = Standard_False;
787 TopTools_DataMapOfShapeListOfShape SlidMap;
790 if(Sliding && counter1 > counter) {
791 TopTools_ListIteratorOfListOfShape it;
792 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm;
793 TopExp_Explorer EX2(w, TopAbs_EDGE);
794 Standard_Integer ii = 0;
795 for(; EX2.More(); EX2.Next()) {
796 const TopoDS_Edge& E = TopoDS::Edge(EX2.Current());
798 if(ii >= counter && ii <= counter1) {
799 it.Initialize(NewListOfEdges);
800 Standard_Integer jj = 0;
801 for(; it.More(); it.Next()) {
802 const TopoDS_Edge& e2 = TopoDS::Edge(it.Value());
804 if(jj== (ii - counter +1)) {
805 itm.Initialize(mySlface);
806 for(; itm.More(); itm.Next()) {
807 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
808 const TopTools_ListOfShape& ledg = itm.Value();
809 TopTools_ListIteratorOfListOfShape itedg(ledg);
810 //Standard_Integer iiii = 0;
811 for(; itedg.More(); itedg.Next()) {
812 const TopoDS_Edge& e1 = TopoDS::Edge(itedg.Value());
814 if(!SlidMap.IsBound(fac)) {
815 TopTools_ListOfShape thelist2;
816 SlidMap.Bind(fac, thelist2);
818 SlidMap(fac).Append(E);
832 // ---Arguments de LocOpe_LinearForm : arguments du prism
836 BB.MakeFace(F, myPln, myTol);
844 // ---Cas sans glissement : construction de la face profil
848 if (Modify) cout << " Sliding failure" << endl;
849 cout << " no Sliding" << endl;
852 TopExp_Explorer explo1(BndFace, TopAbs_WIRE);
853 TopoDS_Wire WWW = TopoDS::Wire(explo1.Current());
854 BRepTools_WireExplorer explo(WWW);
858 TopoDS_Vertex NewV1, NewV2, LastV, v;
859 NewV1.Nullify(); NewV2.Nullify(); LastV.Nullify();
861 for(; explo.More(); explo.Next()) {
862 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
863 TopoDS_Vertex v1 = TopExp::FirstVertex(e,Standard_True);
864 TopoDS_Vertex v2 = TopExp::LastVertex(e,Standard_True);
866 Standard_Real f, l;//, t;
867 Handle(Geom_Curve) ln = BRep_Tool::Curve(e, f, l);
868 // Handle(Geom_Curve) lln = BRep_Tool::Curve(e, f, l);
869 // Handle(Geom_Curve) ln;
870 // if(e.Orientation() == TopAbs_REVERSED) {
871 // ln = Handle(Geom_Curve)::DownCast(lln->Reversed());
872 // v = v1; v1 = v2; v2= v;
873 // f = IntPar(ln, BRep_Tool::Pnt(v1));
874 // l = IntPar(ln, BRep_Tool::Pnt(v2));
878 Handle(Geom2d_Curve) l2d = GeomAPI::To2d(ln, Plane->Pln());
879 Geom2dAPI_InterCurveCurve intcc(l2d, ln2d, Precision::Confusion());
880 TopoDS_Vertex VV; VV.Nullify();
881 TopoDS_Edge ee1, ee2;
883 if(intcc.NbPoints() > 0) {
884 gp_Pnt2d P = intcc.Point(1);
886 myPln->D0(P.X(), P.Y(), point);
887 Standard_Real par = IntPar(ln, point);
888 if(f <= par && l >= par) {
889 Bu.MakeVertex(VV, point, Precision::Confusion());
893 if(VV.IsNull() && NewV1.IsNull()) continue;
895 if(!VV.IsNull() && NewV1.IsNull()) {
898 BRepLib_MakeEdge ee1(NewV1, LastV);
903 if(VV.IsNull() && !NewV1.IsNull()) {
904 BRepLib_MakeEdge ee1(LastV, v2);
910 if(!VV.IsNull() && !NewV1.IsNull()) {
912 BRepLib_MakeEdge ee1(LastV, NewV2);
915 BRepLib_MakeEdge ee2(LastV, NewV1);
921 BRepLib_MakeFace newbndface(myPln->Pln(), Wiwiwi, Standard_True);
922 TopoDS_Face NewBndFace = TopoDS::Face(newbndface.Shape());
924 BRepTopAdaptor_FClass2d Cl(NewBndFace, Precision::Confusion());
925 Standard_Real paru, parv;
926 ElSLib::Parameters(myPln->Pln(), CheckPnt, paru, parv);
927 gp_Pnt2d checkpnt2d(paru, parv);
928 if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
929 //modified by NIZNHY-PKV Fri Mar 22 16:52:52 2002 f
930 //BRepAlgo_Cut c(BndFace, NewBndFace);
931 BRepAlgoAPI_Cut c(BndFace, NewBndFace);
932 //modified by NIZNHY-PKV Fri Mar 22 16:52:57 2002 t
933 TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
934 const TopoDS_Wire& w = TopoDS::Wire(exp.Current());
935 // akm 13/02/02 : we know the plane. Why not to use it?
936 // BRepLib_MakeFace ff(w);
937 BRepLib_MakeFace ff(myPln->Pln(), w, Standard_True);
938 NewBndFace = TopoDS::Face(ff.Shape());
942 if(!BRepAlgo::IsValid(NewBndFace)) {
944 cout << "Invalid new bounding face" << endl;
946 myStatusError = BRepFeat_InvShape;
951 BndFace = NewBndFace;
955 Standard_Boolean ProfileOK;
956 ProfileOK = NoSlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,
957 bnd,BndFace,CheckPnt,
958 FirstFace,LastFace,FirstVertex,LastVertex,
959 FirstEdge,LastEdge,OnFirstFace,OnLastFace);
963 cout << "Not computable" << endl;
964 if (trc) cout << " Face profile not computable" << endl;
966 myStatusError = BRepFeat_NoFaceProf;
972 // ---Propagation sur les faces du shape initial
973 // pour trouver les faces concernees par la nervure
974 Standard_Boolean falseside = Standard_True;
975 Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
976 // Controle si on a ce qu`il faut pour avoir la matiere du bon cote
977 if(falseside == Standard_False) {
979 cout << " Verify plane and wire orientation" << endl;
981 myStatusError = BRepFeat_FalseSide;
988 TopTools_ListIteratorOfListOfShape it;
989 it.Initialize(SliList);
994 BB.MakeShell(TopoDS::Shell(comp));
996 for(; it.More(); it.Next()) {
997 BB.Add(comp, it.Value());
1006 mySliding = Sliding;
1008 TopExp_Explorer exp;
1009 for ( exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
1010 TopTools_ListOfShape thelist3;
1011 myMap.Bind(exp.Current(), thelist3);
1012 myMap(exp.Current()).Append(exp.Current());
1018 //=======================================================================
1020 //purpose : add elements de collage
1021 //=======================================================================
1023 void BRepFeat_MakeRevolutionForm::Add(const TopoDS_Edge& E,
1024 const TopoDS_Face& F)
1027 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1028 if (trc) cout << "BRepFeat_MakeRevolutionForm::Add" << endl;
1030 if(mySlface.IsEmpty()) {
1031 TopExp_Explorer exp;
1032 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
1033 if (exp.Current().IsSame(F)) {
1038 Standard_ConstructionError::Raise();
1041 if (!mySlface.IsBound(F)) {
1042 TopTools_ListOfShape thelist;
1043 mySlface.Bind(F, thelist);
1045 TopTools_ListIteratorOfListOfShape itl(mySlface(F));
1046 for (; itl.More();itl.Next()) {
1047 if (itl.Value().IsSame(E)) {
1052 mySlface(F).Append(E);
1059 //=======================================================================
1060 //function : Perform
1061 //purpose : construction
1062 //=======================================================================
1064 void BRepFeat_MakeRevolutionForm::Perform()
1067 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1068 if (trc) cout << "BRepFeat_MakeRevolutionForm::Perform()" << endl;
1070 if(mySbase.IsNull() || mySkface.IsNull() || myPbase.IsNull()) {
1072 if (trc) cout << " Fields not initialized" << endl;
1074 myStatusError = BRepFeat_NotInitialized;
1081 TopExp_Explorer exx(myPbase, TopAbs_VERTEX);
1082 for(; exx.More(); exx.Next()) {
1083 const TopoDS_Vertex& vv = TopoDS::Vertex(exx.Current());
1085 Pt = BRep_Tool::Pnt(vv);
1092 T.SetRotation(myAxe, -myAngle2);
1093 BRepBuilderAPI_Transform trsf(T);
1094 trsf.Perform(myPbase, Standard_False);
1095 TopoDS_Face Pbase = TopoDS::Face(trsf.Shape());
1096 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter(myLFMap);
1097 for(; iter.More(); iter.Next()) {
1098 const TopoDS_Shape& e1 = iter.Value().First();
1099 TopExp_Explorer ex1(myPbase, TopAbs_EDGE);
1100 TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
1101 for(; ex1.More(); ex1.Next()) {
1102 if(ex1.Current().IsSame(e1)) {
1103 myLFMap(iter.Key()).Clear();
1104 myLFMap(iter.Key()).Append(ex2.Current());
1110 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter1(mySlface);
1111 for(; iter1.More(); iter1.Next()) {
1112 const TopoDS_Shape& f1 = iter1.Key();
1113 const TopoDS_Shape& e1 = iter1.Value().First();
1114 TopExp_Explorer ex1(myPbase, TopAbs_EDGE);
1115 TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
1116 for(; ex1.More(); ex1.Next()) {
1117 const TopoDS_Shape& E1 = ex1.Current();
1118 const TopoDS_Shape& E2 = ex2.Current();
1120 mySlface(f1).Clear();
1121 mySlface(f1).Append(E2);
1127 trsf.Perform(mySkface, Standard_False);
1128 // flo : verif si il faut bien reaffecter le champ mySkface
1129 // TopoDS_Face mySkface = TopoDS::Face(trsf.Shape());
1130 mySkface = TopoDS::Face(trsf.Shape());
1133 LocOpe_RevolutionForm theForm;
1134 theForm.Perform(myPbase, myAxe, (myAngle1+myAngle2));
1135 TopoDS_Shape VraiForm = theForm.Shape(); // la primitive non-coupe
1137 // gestion de descendants
1138 MajMap(myPbase,theForm,myMap,myFShape,myLShape);
1144 gp_Pln Pln0 = myPln->Pln();
1145 BRepLib_MakeFace f(Pln0);
1148 gp_Vec vec1 = myHeight1*Normal(f, Pt);
1149 gp_Vec vec2 = -myHeight2*Normal(f, Pt);
1151 gp_Pln Pln1 = Pln0.Translated(vec1);
1152 gp_Pln Pln2 = Pln0.Translated(vec2);
1154 BRepLib_MakeFace ff1(Pln1);
1155 BRepLib_MakeFace ff2(Pln2);
1156 TopoDS_Face f1 = TopoDS::Face(ff1.Shape());
1157 TopoDS_Face f2 = TopoDS::Face(ff2.Shape());
1158 BRepFeat::FaceUntil(mySbase, f1);
1159 BRepFeat::FaceUntil(mySbase, f2);
1161 LocOpe_CSIntersector ASI1(f1);
1162 LocOpe_CSIntersector ASI2(f2);
1164 Handle(Geom_Line) normale = new Geom_Line(Pt, vec1);
1165 TColGeom_SequenceOfCurve scur;
1166 scur.Append(normale);
1171 if(!ASI1.IsDone() || !ASI2.IsDone() ||
1172 ASI1.NbPoints(1) != 1 || ASI2.NbPoints(1) != 1) {
1174 if (trc) cout << " Intersection failure" << endl;
1176 myStatusError = BRepFeat_BadIntersect;
1181 TopAbs_Orientation Ori1 = ASI1.Point(1,1).Orientation();
1182 TopAbs_Orientation Ori2 = TopAbs::Reverse(ASI2.Point(1,1).Orientation());
1183 TopoDS_Face FF1 = ASI1.Point(1,1).Face();
1184 TopoDS_Face FF2 = ASI2.Point(1,1).Face();
1188 B.MakeCompound(TopoDS::Compound(Comp));
1189 TopoDS_Solid S1 = BRepFeat::Tool(f1,FF1,Ori1);
1190 TopoDS_Solid S2 = BRepFeat::Tool(f2,FF2,Ori2);
1191 if (!S1.IsNull()) B.Add(Comp,S1);
1192 if (!S2.IsNull()) B.Add(Comp,S2);
1194 //modified by NIZNHY-PKV Fri Mar 22 16:53:20 2002 f
1195 //BRepAlgo_Cut trP(VraiForm,Comp);
1196 BRepAlgoAPI_Cut trP(VraiForm,Comp);
1197 //modified by NIZNHY-PKV Fri Mar 22 16:53:23 2002 t
1198 // coupe de la nervure par deux plans parallels
1199 TopTools_DataMapOfShapeListOfShape SlidingMap;
1201 // gestion de descendants
1203 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape it1;
1204 it1.Initialize(myMap);
1205 for(; it1.More(); it1.Next()) {
1206 const TopoDS_Shape& orig = it1.Key();
1207 if(it1.Value().IsEmpty()) continue;
1208 const TopoDS_Shape& sh = it1.Value().First();
1209 exx.Init(VraiForm, TopAbs_FACE);
1210 for(; exx.More(); exx.Next()) {
1211 const TopoDS_Face& fac = TopoDS::Face(exx.Current());
1212 TopExp_Explorer exx1(fac, TopAbs_WIRE);
1213 const TopoDS_Wire& thew = TopoDS::Wire(exx1.Current());
1214 if(thew.IsSame(myFShape)) {
1215 const TopTools_ListOfShape& desfaces = trP.Modified(f2);
1216 myMap(myFShape) = desfaces;
1219 else if(thew.IsSame(myLShape)) {
1220 const TopTools_ListOfShape& desfaces = trP.Modified(f1);
1221 myMap(myLShape) = desfaces;
1224 if(fac.IsSame(sh)) {
1225 if (trP.IsDeleted(fac)) {
1228 const TopTools_ListOfShape& desfaces = trP.Modified(fac);
1229 if(!desfaces.IsEmpty()) {
1230 myMap(orig).Clear();
1231 myMap(orig) = trP.Modified(fac);
1238 exx.Init(VraiForm, TopAbs_FACE);
1239 for(; exx.More(); exx.Next()) {
1240 const TopoDS_Face& fac = TopoDS::Face(exx.Current());
1241 TopTools_ListOfShape thelist;
1242 SlidingMap.Bind(fac, thelist);
1243 if (trP.IsDeleted(fac)) {
1246 const TopTools_ListOfShape& desfaces = trP.Modified(fac);
1247 if(!desfaces.IsEmpty())
1248 SlidingMap(fac) = desfaces;
1250 SlidingMap(fac).Append(fac);
1255 // gestion des faces de glissement
1256 SetGluedFaces(mySlface, theForm, SlidingMap, myGluedF);
1258 VraiForm = trP.Shape(); // primitive coupee
1260 if(!myGluedF.IsEmpty())
1261 myPerfSelection = BRepFeat_NoSelection;
1263 myPerfSelection = BRepFeat_SelectionSh;
1265 exx.Init(myPbase, TopAbs_EDGE);
1266 for(; exx.More(); exx.Next()) {
1267 const TopoDS_Edge& e = TopoDS::Edge(exx.Current());
1268 if(!myMap.IsBound(e)) {
1270 if (trc) cout << " Sliding face not in Base shape" << endl;
1272 myStatusError = BRepFeat_IncSlidFace;
1278 myGShape = VraiForm;
1280 if(!myGluedF.IsEmpty() && !mySUntil.IsNull()) {
1282 cout << "The case is not computable" << endl;
1283 if (trc) cout << " Glued faces not empty and Until shape not null" << endl;
1285 myStatusError = BRepFeat_InvShape;
1290 LFPerform(); // reconstruction topologique
1294 //=======================================================================
1295 //function : Propagate
1296 //purpose : propagation sur les faces du shape inital, rechrche des faces
1297 // concernees par la nervure
1298 //=======================================================================
1300 Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& SliList,
1301 const TopoDS_Face& fac,
1302 const gp_Pnt& Firstpnt,
1303 const gp_Pnt& Lastpnt,
1304 Standard_Boolean& falseside)
1307 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
1308 if (trc) cout << "BRepFeat_MakeRevolutionForm::Propagate" << endl;
1310 gp_Pnt Firstpoint = Firstpnt;
1311 gp_Pnt Lastpoint = Lastpnt;
1313 Standard_Boolean result = Standard_True;
1314 TopoDS_Face CurrentFace, saveFace;
1315 CurrentFace = TopoDS::Face(SliList.First());
1316 saveFace = CurrentFace;
1317 // BRepBuilderAPI_MakeFace fac(myPln);
1318 Standard_Boolean LastOK = Standard_False, FirstOK= Standard_False;
1319 TopoDS_Vertex v1, v2, v3, v4, Vert;
1320 //modified by NIZNHY-PKV Fri Mar 22 16:54:09 2002 f
1321 //BRepAlgo_Section sect (fac, CurrentFace, Standard_False);
1322 BRepAlgoAPI_Section sect (fac, CurrentFace, Standard_False);
1323 //modified by NIZNHY-PKV Fri Mar 22 16:54:14 2002 t
1324 sect.Approximation(Standard_True);
1329 Standard_Integer ii = 0;
1330 for (Ex.Init(sect.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1333 e = TopoDS::Edge(Ex.Current());
1336 e1 = TopoDS::Edge(Ex.Current());
1341 falseside = Standard_False;
1342 return Standard_False;
1345 //modified by NIZNHY-PKV Tue Apr 2 15:08:23 2002 f
1347 Standard_Real aTolV1, aTolV2;
1348 myListOfEdges.Clear();
1349 TopTools_ListOfShape thelist;
1350 mySlface.Bind(CurrentFace, thelist);
1351 mySlface(CurrentFace).Append(e1);
1353 myListOfEdges.Append(e1);
1355 v1 = TopExp::FirstVertex(e1,Standard_True);
1356 v2 = TopExp::LastVertex (e1,Standard_True);
1358 FP = BRep_Tool::Pnt(v1);
1359 LP = BRep_Tool::Pnt(v2);
1361 aTolV1=BRep_Tool::Tolerance(v1);
1362 aTolV2=BRep_Tool::Tolerance(v2);
1364 if(FP.Distance(Firstpoint) <= aTolV1 ||
1365 FP.Distance(Lastpoint) <= aTolV1) {
1366 FirstOK = Standard_True;
1368 if(LP.Distance(Firstpoint)<= aTolV2 ||
1369 LP.Distance(Lastpoint) <= aTolV2) {
1370 LastOK = Standard_True;
1373 if(LastOK && FirstOK) {
1378 myListOfEdges.Clear();
1381 //modified by NIZNHY-PKV Tue Apr 2 15:08:26 2002 t
1384 myListOfEdges.Clear();
1385 TopTools_ListOfShape thelist1;
1386 mySlface.Bind(CurrentFace, thelist1);
1387 mySlface(CurrentFace).Append(e);
1389 myListOfEdges.Append(e);
1391 // mySlface.Bind(CurrentFace,TopTools_ListOfShape());
1392 mySlface(CurrentFace).Append(e1);
1393 // myListOfEdges.Append(e1);
1395 v1 = TopExp::FirstVertex(e,Standard_True);
1396 v2 = TopExp::LastVertex(e,Standard_True);
1397 v3 = TopExp::FirstVertex(e1,Standard_True);
1398 v4 = TopExp::LastVertex(e1,Standard_True);
1399 gp_Pnt p1, p2, p3, p4;
1400 p1 = BRep_Tool::Pnt(v1); FP = p1;
1401 p2 = BRep_Tool::Pnt(v2); LP = p2;
1402 p3 = BRep_Tool::Pnt(v3);
1403 p4 = BRep_Tool::Pnt(v4);
1404 if(p1.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)) {
1405 if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) {
1406 FirstOK = Standard_True;
1409 else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) {
1410 FirstOK = Standard_True;
1417 else if(p1.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1418 if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) {
1419 FirstOK = Standard_True;
1422 else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) {
1423 FirstOK = Standard_True;
1430 else if(p2.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)) {
1431 if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) {
1432 LastOK = Standard_True;
1435 else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) {
1436 LastOK = Standard_True;
1443 else if(p2.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1444 if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) {
1445 LastOK = Standard_True;
1448 else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) {
1449 LastOK = Standard_True;
1461 //Standard_Real f, l;
1463 myListOfEdges.Clear();
1464 TopTools_ListOfShape thelist2;
1465 mySlface.Bind(CurrentFace, thelist2);
1466 mySlface(CurrentFace).Append(e);
1468 myListOfEdges.Append(e);
1470 v1 = TopExp::FirstVertex(e,Standard_True);
1471 v2 = TopExp::LastVertex(e,Standard_True);
1473 FP = BRep_Tool::Pnt(v1);
1474 LP = BRep_Tool::Pnt(v2);
1476 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)
1477 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1478 FirstOK = Standard_True;
1480 if(LP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)
1481 || LP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1482 LastOK = Standard_True;
1485 if(LastOK && FirstOK) {
1490 TopTools_IndexedDataMapOfShapeListOfShape mapedges;
1491 TopExp::MapShapesAndAncestors(mySbase, TopAbs_EDGE, TopAbs_FACE, mapedges);
1493 TopoDS_Edge FirstEdge;
1495 TopoDS_Vertex Vprevious; Vprevious.Nullify();
1496 TopoDS_Vertex Vpreprevious; Vpreprevious.Nullify();
1499 // retrouver l'edge connexe a v1:
1501 if(!v1.IsNull()) pt= BRep_Tool::Pnt(v1);
1503 if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious);
1505 if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious);
1507 if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) ||
1508 (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) {
1509 falseside = Standard_False;
1510 return Standard_False;
1513 for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1514 const TopoDS_Edge& e = TopoDS::Edge(ex.Current());
1516 BRepExtrema_ExtPC projF(v1, e);
1518 if(projF.IsDone() && projF.NbExt() >=1) {
1519 Standard_Real dist2min = RealLast();
1520 Standard_Integer index = 0;
1521 for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) {
1522 if (projF.SquareDistance(sol) <= dist2min) {
1524 dist2min = projF.SquareDistance(sol);
1528 if (dist2min <= BRep_Tool::Tolerance(e) * BRep_Tool::Tolerance(e)) {
1536 const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1537 TopTools_ListIteratorOfListOfShape It(L);
1539 for (; It.More(); It.Next()) {
1540 const TopoDS_Face& FF = TopoDS::Face(It.Value());
1541 if (!FF.IsSame(CurrentFace)) {
1547 //modified by NIZNHY-PKV Fri Mar 22 16:54:28 2002 f
1548 //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False);
1549 BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False);
1550 //modified by NIZNHY-PKV Fri Mar 22 16:54:33 2002 t
1551 sectf.Approximation(Standard_True);
1555 for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1556 edg1 = TopoDS::Edge(Ex.Current());
1557 gp_Pnt ppp1 = BRep_Tool::Pnt(TopExp::FirstVertex(edg1,Standard_True));
1558 gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg1,Standard_True));
1559 if(ppp1.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1) ||
1560 ppp2.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1))
1564 TopTools_ListOfShape thelist3;
1565 mySlface.Bind(CurrentFace, thelist3);
1566 mySlface(CurrentFace).Append(edg1);
1567 myListOfEdges.Append(edg1);
1569 if (!edg1.IsNull()) SliList.Prepend(CurrentFace);
1570 else return Standard_False;
1572 Vert = TopExp::FirstVertex(edg1,Standard_True);
1573 gp_Pnt PP = BRep_Tool::Pnt(Vert);
1574 FP = BRep_Tool::Pnt(v1);
1575 Standard_Real tol = BRep_Tool::Tolerance(edg1);
1576 Standard_Real tol1 = BRep_Tool::Tolerance(v1);
1577 if(tol1 > tol) tol = tol1;
1578 Standard_Real dist = PP.Distance(FP);
1580 Vpreprevious = Vprevious;
1582 v1 = TopExp::LastVertex(edg1,Standard_True);
1585 Vpreprevious = Vprevious;
1590 FP = BRep_Tool::Pnt(v1);
1592 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)
1593 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1594 FirstOK = Standard_True;
1598 CurrentFace = saveFace;
1599 Vprevious.Nullify();
1600 Vpreprevious.Nullify();
1603 // retrouver l'edge connexe a v2:
1605 if(!v2.IsNull()) pt= BRep_Tool::Pnt(v2);
1607 if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious);
1609 if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious);
1611 if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) ||
1612 (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) {
1613 falseside = Standard_False;
1614 return Standard_False;
1617 for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1618 const TopoDS_Edge& e = TopoDS::Edge(ex.Current());
1619 BRepExtrema_ExtPC projF(v2, e);
1621 if(projF.IsDone() && projF.NbExt() >=1) {
1622 Standard_Real dist2min = RealLast();
1623 Standard_Integer index = 0;
1624 for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) {
1625 if (projF.SquareDistance(sol) <= dist2min) {
1627 dist2min = projF.SquareDistance(sol);
1631 if (dist2min <= BRep_Tool::Tolerance(e) * BRep_Tool::Tolerance(e)) {
1639 const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1640 TopTools_ListIteratorOfListOfShape It(L);
1642 for (; It.More(); It.Next()) {
1643 const TopoDS_Face& FF = TopoDS::Face(It.Value());
1644 if (!FF.IsSame(CurrentFace)) {
1652 //modified by NIZNHY-PKV Fri Mar 22 16:54:45 2002 f
1653 //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False);
1654 BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False);
1655 //modified by NIZNHY-PKV Fri Mar 22 16:54:52 2002 t
1656 sectf.Approximation(Standard_True);
1660 for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1661 edg2 = TopoDS::Edge(Ex.Current());
1662 gp_Pnt ppp1 = BRep_Tool::Pnt(TopExp::FirstVertex(edg2,Standard_True));
1663 gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg2,Standard_True));
1664 if(ppp1.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2) ||
1665 ppp2.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2))
1668 TopTools_ListOfShape thelist4;
1669 mySlface.Bind(CurrentFace, thelist4);
1670 mySlface(CurrentFace).Append(edg2);
1671 myListOfEdges.Append(edg2);
1673 if (!edg2.IsNull()) SliList.Append(CurrentFace);
1674 else return Standard_False;
1676 Vert = TopExp::FirstVertex(edg2,Standard_True);
1677 gp_Pnt PP = BRep_Tool::Pnt(Vert);
1678 FP = BRep_Tool::Pnt(v2);
1679 if (PP.Distance(FP)<= BRep_Tool::Tolerance(v2)) {
1680 Vpreprevious = Vprevious;
1682 v2 = TopExp::LastVertex(edg2,Standard_True);
1687 FP = BRep_Tool::Pnt(v2);
1690 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)
1691 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1692 LastOK = Standard_True;
1695 if(!e1.IsNull()) myListOfEdges.Append(e1);
1701 //=======================================================================
1703 //purpose : gestion de descendants
1704 //=======================================================================
1706 static void MajMap(const TopoDS_Shape& theB,
1707 const LocOpe_RevolutionForm& theP,
1708 TopTools_DataMapOfShapeListOfShape& theMap, // myMap
1709 TopoDS_Shape& theFShape, // myFShape
1710 TopoDS_Shape& theLShape) // myLShape
1712 TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
1714 theFShape = exp.Current();
1715 TopTools_ListOfShape thelist;
1716 theMap.Bind(theFShape, thelist);
1717 for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
1718 const TopoDS_Shape& sh = exp.Current();
1719 theMap(theFShape).Append(sh);
1723 exp.Init(theP.LastShape(),TopAbs_WIRE);
1725 theLShape = exp.Current();
1726 TopTools_ListOfShape thelist1;
1727 theMap.Bind(theLShape, thelist1);
1728 for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
1729 const TopoDS_Shape& sh = exp.Current();
1730 theMap(theLShape).Append(sh);
1734 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
1735 if (!theMap.IsBound(exp.Current())) {
1737 const TopoDS_Edge& e =
1739 TopoDS::Edge(exp.Current());
1740 TopTools_ListOfShape thelist2;
1741 theMap.Bind(exp.Current(), thelist2);
1742 theMap(exp.Current()) = theP.Shapes(exp.Current());
1748 //=======================================================================
1749 //function : SetGluedFaces
1750 //purpose : gestion des faces de glissement
1751 //=======================================================================
1753 static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
1754 LocOpe_RevolutionForm& thePrism,
1755 const TopTools_DataMapOfShapeListOfShape& SlidingMap,
1756 TopTools_DataMapOfShapeShape& theMap)
1759 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap);
1760 if(!theSlmap.IsEmpty()) {
1761 for (; itm.More(); itm.Next()) {
1762 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
1763 const TopTools_ListOfShape& ledg = itm.Value();
1764 TopTools_ListIteratorOfListOfShape it;
1765 for (it.Initialize(ledg); it.More(); it.Next()) {
1766 const TopTools_ListOfShape& gfac = thePrism.Shapes(it.Value());
1767 if (gfac.Extent() != 1) {
1769 cout << "Pb SetGluedFace" << endl;
1772 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iterm(SlidingMap);
1773 for(; iterm.More(); iterm.Next()) {
1774 const TopoDS_Face& ff = TopoDS::Face(iterm.Key());
1775 const TopTools_ListOfShape& lfaces = iterm.Value();
1776 if(lfaces.IsEmpty()) continue;
1777 const TopoDS_Face& fff = TopoDS::Face(lfaces.First());
1778 if(gfac.First().IsSame(ff)) theMap.Bind(fff,fac);