1 // Created on: 1997-10-14
2 // Created by: Olga KOULECHOVA
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <BRepFeat_MakeRevolutionForm.ixx>
25 #include <BRepFeat.hxx>
28 #include <LocOpe_RevolutionForm.hxx>
29 #include <LocOpe_CSIntersector.hxx>
30 #include <LocOpe_PntFace.hxx>
31 #include <LocOpe_Gluer.hxx>
32 #include <LocOpe_FindEdges.hxx>
40 #include <gp_Vec2d.hxx>
41 #include <gp_Pnt2d.hxx>
43 #include <Geom_Curve.hxx>
45 #include <Geom2d_Curve.hxx>
46 #include <Geom2d_Line.hxx>
48 #include <Geom_Line.hxx>
49 #include <Geom_Circle.hxx>
50 #include <Geom_Plane.hxx>
51 #include <Geom_Surface.hxx>
52 #include <Geom_CylindricalSurface.hxx>
53 #include <Geom_ConicalSurface.hxx>
54 #include <Geom_ToroidalSurface.hxx>
55 #include <Geom_RectangularTrimmedSurface.hxx>
57 #include <Geom_TrimmedCurve.hxx>
58 #include <GeomProjLib.hxx>
60 #include <Geom2dAPI_InterCurveCurve.hxx>
61 #include <Geom2dAPI_ExtremaCurveCurve.hxx>
62 #include <Geom2d_Curve.hxx>
63 #include <Geom2d_Curve.hxx>
66 #include <GeomAPI.hxx>
67 #include <GeomAPI_ProjectPointOnCurve.hxx>
69 #include <TColgp_SequenceOfPnt.hxx>
71 #include <TColGeom_SequenceOfCurve.hxx>
73 #include <TColStd_Array1OfReal.hxx>
74 #include <IntRes2d_IntersectionPoint.hxx>
76 #include <BRepTools_WireExplorer.hxx>
78 #include <BRep_Tool.hxx>
79 #include <BRep_Builder.hxx>
81 #include <TopExp_Explorer.hxx>
84 #include <TopTools_MapOfShape.hxx>
85 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
86 #include <TopTools_ListOfShape.hxx>
87 #include <TopTools_ListIteratorOfListOfShape.hxx>
88 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
89 #include <TopTools_MapIteratorOfMapOfShape.hxx>
90 #include <TopOpeBRepBuild_HBuilder.hxx>
91 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
93 #include <TColgp_Array1OfPnt.hxx>
95 #include <TColGeom_Array1OfCurve.hxx>
98 #include <TopoDS_Shape.hxx>
99 #include <TopoDS_Face.hxx>
101 #include <BRepLib_MakeVertex.hxx>
102 #include <BRepLib_MakeEdge.hxx>
103 #include <BRepLib_MakeFace.hxx>
105 #include <BRepTools.hxx>
107 #include <BRepPrimAPI_MakeBox.hxx>
108 #include <BRepBuilderAPI_MakeFace.hxx>
110 #include <BRepAlgo.hxx>
112 //modified by NIZNHY-PKV Fri Mar 22 16:56:15 2002
113 //#include <BRepAlgo_Cut.hxx>
114 //#include <BRepAlgo_Section.hxx>
115 //#include <BRepAlgo_Common.hxx>
116 #include <BRepAlgoAPI_Cut.hxx>
117 #include <BRepAlgoAPI_Section.hxx>
118 #include <BRepAlgoAPI_Common.hxx>
119 //modified by NIZNHY-PKV Fri Mar 22 16:56:17 2002 t
121 #include <BRepBuilderAPI_Transform.hxx>
122 #include <BRepExtrema_ExtPC.hxx>
123 #include <BRepExtrema_ExtCF.hxx>
125 #include <BRepTools_Modifier.hxx>
126 #include <BRepTools_TrsfModification.hxx>
128 #include <BRepTopAdaptor_FClass2d.hxx>
130 #include <Standard_ConstructionError.hxx>
132 #include <Precision.hxx>
135 #include <ElCLib.hxx>
136 #include <ElSLib.hxx>
139 #include <GeomLProp_CLProps.hxx>
142 extern Standard_Boolean BRepFeat_GettraceFEAT();
143 extern Standard_Boolean BRepFeat_GettraceFEATRIB();
146 static void MajMap(const TopoDS_Shape&, // base
147 const LocOpe_RevolutionForm&,
148 TopTools_DataMapOfShapeListOfShape&, // myMap
149 TopoDS_Shape&, // myFShape
150 TopoDS_Shape&); // myLShape
152 static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
153 LocOpe_RevolutionForm&,
154 const TopTools_DataMapOfShapeListOfShape& SlidingMap,
155 TopTools_DataMapOfShapeShape&);
157 //=======================================================================
160 //=======================================================================
162 void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
163 const TopoDS_Wire& W,
164 const Handle(Geom_Plane)& Plane,
166 const Standard_Real H1,
167 const Standard_Real H2,
168 const Standard_Integer Mode,
169 Standard_Boolean& Modify)
172 Standard_Boolean trc = BRepFeat_GettraceFEAT();
173 if (trc) cout << "BRepFeat_MakeRevolutionForm::Init" << endl;
175 Standard_Boolean RevolRib = Standard_True;
178 // modify = 0 if it is not required to make sliding
179 // = 1 if it is intended to try to make sliding
180 Standard_Boolean Sliding = Modify;
183 Handle(Geom_Line) Line = new Geom_Line(Axis);
184 Standard_Real LineFirst, LineLast;
186 LocOpe_CSIntersector ASI(Sbase);
187 TColGeom_SequenceOfCurve scur;
191 if(ASI.IsDone() && ASI.NbPoints(1) >= 2) {
192 LineLast = ASI.Point(1, ASI.NbPoints(1)).Parameter();
193 LineFirst = ASI.Point(1, 1).Parameter();
196 LineFirst = RealFirst();
197 LineLast = RealLast();
200 Handle(Geom2d_Curve) ln2d = GeomAPI::To2d(Line, Plane->Pln());
203 Standard_Real Rad = RealLast();
205 exx.Init(W, TopAbs_EDGE);
206 for(; exx.More(); exx.Next()) {
207 const TopoDS_Edge& e = TopoDS::Edge(exx.Current());
209 Handle(Geom_Curve) c = BRep_Tool::Curve(e, f, l);
210 Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, Plane->Pln());
211 Geom2dAPI_ExtremaCurveCurve extr(ln2d, c2d, LineFirst, LineLast,f,l);
212 Quantity_Length L = RealLast();
213 if(extr.NbExtrema() >= 1) {
214 L = extr.LowerDistance();
216 gp_Pnt p1 = c->Value(f);
217 gp_Pnt p2 = c->Value(l);
218 GeomAPI_ProjectPointOnCurve proj1(p1, Line);
219 GeomAPI_ProjectPointOnCurve proj2(p2, Line);
220 if(proj1.NbPoints() < 1 || proj2.NbPoints() < 1) {
222 if (trc) cout << " No projection points" << endl;
224 myStatusError = BRepFeat_NoProjPt;
228 Standard_Real par1 = proj1.Distance(1);
229 Standard_Real par2 = proj2.Distance(1);
230 Standard_Real Par = Min(par1, par2);
232 if(L<Rad && L > 0.) Rad = L;
235 Standard_Real height = Min(H1, H2);
237 if(Rad <= height) Rad = height + 0.01*height;
239 myAngle1 = asin(H1/Rad) + M_PI/10.;
240 myAngle2 = asin(H2/Rad) + M_PI/10.;
242 if((myAngle1 - M_PI/2) > Precision::Confusion())
244 if((myAngle2 - M_PI/2) > Precision::Confusion())
251 myFuse = Standard_False;
252 else // if(Mode == 1)
253 myFuse = Standard_True;
256 if (myFuse) cout << " Fuse" << endl;
257 if (!myFuse) cout << " Cut" << endl;
261 // ---Determination Tolerance : tolerance max on parameters
262 myTol = Precision::Confusion();
264 exx.Init(W, TopAbs_VERTEX);
265 for(; exx.More(); exx.Next()) {
266 const Standard_Real& tol = BRep_Tool::
267 Tolerance(TopoDS::Vertex(exx.Current()));
268 if(tol > myTol) myTol = tol;
271 exx.Init(Sbase, TopAbs_VERTEX);
272 for(; exx.More(); exx.Next()) {
273 const Standard_Real& tol = BRep_Tool::
274 Tolerance(TopoDS::Vertex(exx.Current()));
275 if(tol > myTol) myTol = tol;
278 TopoDS_Shape aLocalShape = W.Oriented(TopAbs_FORWARD);
279 myWire = TopoDS::Wire(aLocalShape);
280 // myWire = TopoDS::Wire(W.Oriented(TopAbs_FORWARD));
292 // ---Calculate bounding box
295 TopTools_ListOfShape theList;
299 gp_Pnt FirstCorner, LastCorner;
300 Standard_Real bnd = HeightMax(mySbase, U, FirstCorner, LastCorner);
303 BRepPrimAPI_MakeBox Bndbox(FirstCorner, LastCorner);
304 TopoDS_Solid BndBox = Bndbox.Solid();
307 // ---Construction of the working plane face (section bounding box)
308 BRepLib_MakeFace PlaneF(myPln->Pln(), -6.*myBnd,
309 6.*myBnd, -6.*myBnd, 6.*myBnd);
310 TopoDS_Face PlaneFace = TopoDS::Face(PlaneF.Shape());
312 //modified by NIZNHY-PKV Fri Mar 22 16:52:26 2002 f
313 //BRepAlgo_Common PlaneS(BndBox, PlaneFace);
314 BRepAlgoAPI_Common PlaneS(BndBox, PlaneFace);
315 //modified by NIZNHY-PKV Fri Mar 22 16:52:31 2002 t
317 TopoDS_Shape PlaneSect = PlaneS.Shape();
318 EXP.Init(PlaneSect, TopAbs_WIRE);
319 TopoDS_Wire www = TopoDS::Wire(EXP.Current());
320 BRepLib_MakeFace Bndface(myPln->Pln(), www, Standard_True);
321 TopoDS_Face BndFace = TopoDS::Face(Bndface.Shape());
324 // ---Find base faces of the rib
325 TopoDS_Edge FirstEdge, LastEdge;
326 TopoDS_Face FirstFace, LastFace;
327 TopoDS_Vertex FirstVertex, LastVertex;
329 Standard_Boolean OnFirstFace = Standard_False;
330 Standard_Boolean OnLastFace = Standard_False;
331 Standard_Boolean PtOnFirstEdge = Standard_False;
332 Standard_Boolean PtOnLastEdge = Standard_False;
333 TopoDS_Edge OnFirstEdge, OnLastEdge;
334 OnFirstEdge.Nullify();
335 OnLastEdge.Nullify();
337 Standard_Boolean Data = ExtremeFaces(RevolRib, myBnd, myPln, FirstEdge, LastEdge,
338 FirstFace, LastFace, FirstVertex,
339 LastVertex, OnFirstFace, OnLastFace,
340 PtOnFirstEdge, PtOnLastEdge,
341 OnFirstEdge, OnLastEdge);
345 if (trc) cout << " No Extreme faces" << endl;
347 myStatusError = BRepFeat_NoExtFace;
353 // ---Proofing Point for the side of the wire to be filled - material side
354 gp_Pnt CheckPnt = CheckPoint(FirstEdge, bnd/10., myPln);
356 // Standard_Real f, l;
358 // ---Control sliding valid
359 // Many cases when the sliding is abandoned
360 Standard_Integer Concavite = 3; // a priori the profile is not concave
362 myFirstPnt = BRep_Tool::Pnt(FirstVertex);
363 myLastPnt = BRep_Tool::Pnt(LastVertex);
365 // SliList : list of faces concerned by the rib
366 TopTools_ListOfShape SliList;
367 SliList.Append(FirstFace);
369 if(Sliding) { // sliding
371 if (trc) cout << " Sliding" << endl;
373 Handle(Geom_Surface) s = BRep_Tool::Surface(FirstFace);
374 if (s->DynamicType() ==
375 STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
376 s = Handle(Geom_RectangularTrimmedSurface)::
377 DownCast(s)->BasisSurface();
379 if(s->DynamicType() != STANDARD_TYPE(Geom_Plane) &&
380 s->DynamicType() != STANDARD_TYPE(Geom_CylindricalSurface) &&
381 s->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface) &&
382 s->DynamicType() != STANDARD_TYPE(Geom_ToroidalSurface))
383 Sliding = Standard_False;
386 if(Sliding) { // sliding
387 Handle(Geom_Surface) ss = BRep_Tool::Surface(LastFace);
388 if (ss->DynamicType() ==
389 STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
390 ss = Handle(Geom_RectangularTrimmedSurface)::
391 DownCast(ss)->BasisSurface();
393 if(ss->DynamicType() != STANDARD_TYPE(Geom_Plane) &&
394 ss->DynamicType() != STANDARD_TYPE(Geom_CylindricalSurface) &&
395 ss->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface) &&
396 ss->DynamicType() != STANDARD_TYPE(Geom_ToroidalSurface))
397 Sliding = Standard_False;
400 // Control only start and end points no control at the middle to improve
401 // If make a control between Surface and segment 2 points limited
402 // -> too expensive - to improve
403 //gp_Pnt FirstCenter, LastCenter;
404 gp_Circ FirstCircle, LastCircle;
405 Handle(Geom_Curve) FirstCrv, LastCrv;
407 if(Sliding) { // sliding
408 GeomAPI_ProjectPointOnCurve proj(myFirstPnt, Line);
409 if(proj.NbPoints() < 1) {
411 if (trc) cout << " No First Point projection" << endl;
413 myStatusError = BRepFeat_NoProjPt;
417 Standard_Real FirstRayon = proj.Distance(1);
418 gp_Pnt FirstCenter = proj.Point(1);
420 GeomAPI_ProjectPointOnCurve proj1(myLastPnt, Line);
421 if(proj.NbPoints() < 1) {
423 if (trc) cout << " No Last Point projection" << endl;
425 myStatusError = BRepFeat_NoProjPt;
429 Standard_Real LastRayon = proj1.Distance(1);
430 gp_Pnt LastCenter = proj1.Point(1);
432 gp_Vec axv(myAxe.Direction());
433 gp_Ax2 ax2(FirstCenter, axv);
434 gp_Ax2 ax2p(LastCenter, axv);
435 gp_Circ theFC(ax2, FirstRayon);
436 gp_Circ theLC(ax2p, LastRayon);
438 gp_Pnt RFirstPnt1 = myFirstPnt.Rotated(myAxe, myAngle1);
439 gp_Pnt RLastPnt1 = myLastPnt.Rotated(myAxe, myAngle1);
440 gp_Pnt RFirstPnt2 = myFirstPnt.Rotated(myAxe, -myAngle2);
441 gp_Pnt RLastPnt2 = myLastPnt.Rotated(myAxe, -myAngle2);
444 TopoDS_Vertex v1, v2, v3, v4;
445 Bu.MakeVertex(v1, RFirstPnt2, Precision::Confusion());
446 Bu.MakeVertex(v2, RFirstPnt1, Precision::Confusion());
447 Bu.MakeVertex(v3, RLastPnt2, Precision::Confusion());
448 Bu.MakeVertex(v4, RLastPnt1, Precision::Confusion());
450 BRepLib_MakeEdge ee1(theFC, v1, v2);
451 BRepLib_MakeEdge ee2(theLC, v3, v4);
453 if(Sliding && !PtOnFirstEdge) {
454 BRepExtrema_ExtCF ext1(TopoDS::Edge(ee1.Shape()), FirstFace);
455 if(ext1.NbExt() < 1 || ext1.SquareDistance(1) > Precision::SquareConfusion())
456 Sliding = Standard_False;
458 if(Sliding && !PtOnLastEdge) {
459 BRepExtrema_ExtCF ext2(ee2, LastFace); // ExtCF : curves and surfaces
460 if(ext2.NbExt() < 1 || ext2.SquareDistance(1) > Precision::SquareConfusion())
461 Sliding = Standard_False;
463 if(Sliding && PtOnFirstEdge) {
465 FirstCrv = BRep_Tool::Curve(OnFirstEdge, f, l);
466 if(FirstCrv->DynamicType() != STANDARD_TYPE(Geom_Circle))
467 Sliding = Standard_False;
469 Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(FirstCrv);
470 gp_Circ Circ = C1->Circ();
472 gp_Ax1 circax = FirstCircle.Axis();
473 if(!circax.IsCoaxial(myAxe, Precision::Confusion(),
474 Precision::Confusion()))
475 Sliding = Standard_False;
478 if(fabs(FirstCircle.Radius()-FirstRayon) >=
480 // if(abs(FirstCircle.Radius()-FirstRayon) >=
482 Precision::Confusion())
483 Sliding = Standard_False;
488 if(Sliding && PtOnLastEdge) {
490 LastCrv = BRep_Tool::Curve(OnLastEdge, f, l);
491 if(LastCrv->DynamicType() != STANDARD_TYPE(Geom_Circle))
492 Sliding = Standard_False;
494 Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(LastCrv);
495 gp_Circ Circ = C1->Circ();
497 gp_Ax1 circax = LastCircle.Axis();
498 if(!circax.IsCoaxial(myAxe, Precision::Confusion(),
499 Precision::Confusion()))
500 Sliding = Standard_False;
502 Standard_Real rad = LastCircle.Radius();
504 if(fabs(rad - LastRayon) >= Precision::Confusion()) {
506 // if(abs(rad - LastRayon) >= Precision::Confusion()) {
508 Sliding = Standard_False;
516 // Construct a great profile that goes till the bounding box
517 // -> by tangency with first and last edge of the Wire
518 // -> by normals to base faces : statistically better
519 // Intersect everythin to find the final profile
522 // ---case of sliding : construction of the face profile
525 if (trc) cout << " still Sliding" << endl;
528 Standard_Boolean ProfileOK;
529 ProfileOK = SlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,BndFace,CheckPnt,
530 FirstFace,LastFace,FirstVertex,LastVertex,
535 cout << "Not computable" << endl;
536 if (trc) cout << "Face profile not computable" << endl;
538 myStatusError = BRepFeat_NoFaceProf;
544 // ---Propagation on faces of the initial shape
545 // to find the faces concerned by the rib
546 Standard_Boolean falseside = Standard_True;
547 Sliding = Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
548 // Control if there is everything required to have the material at the proper side
549 if(falseside == Standard_False) {
551 cout << " Verify plane and wire orientation" << endl;
553 myStatusError = BRepFeat_FalseSide;
560 // ---Generation of the base profile of the rib
564 TopoDS_Edge thePreviousEdge;
566 thePreviousEdge.Nullify();
568 // counter of the number of edges to fill the map
569 Standard_Integer counter = 1;
571 // ---case of sliding
572 if(Sliding && !myListOfEdges.IsEmpty()) {
573 BRepTools_WireExplorer EX1(myWire);
574 for(; EX1.More(); EX1.Next()) {
575 const TopoDS_Edge& E = EX1.Current();
576 if(!myLFMap.IsBound(E)) {
577 TopTools_ListOfShape theTmpList;
578 myLFMap.Bind(E, theTmpList);
580 if(E.IsSame(FirstEdge)) {
582 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
584 if(!FirstEdge.IsSame(LastEdge)) {
585 pt = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True));
589 Standard_Real fpar = IntPar(cc, myFirstPnt);
590 Standard_Real lpar = IntPar(cc, pt);
591 Handle(Geom_Curve) ccc;
593 ccc = Handle(Geom_Curve)::DownCast(cc->Reversed());
598 if(thePreviousEdge.IsNull()) {
599 BRepLib_MakeVertex v1(myFirstPnt);
600 BRepLib_MakeVertex v2(pt);
601 BRepLib_MakeEdge e(cc, v1, v2);
602 ee1 = TopoDS::Edge(e.Shape());
605 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
606 BRepLib_MakeVertex v2(pt);
608 BRepLib_MakeEdge e(cc, v1, v2);
609 ee1 = TopoDS::Edge(e.Shape());
611 TopoDS_Shape aLocalShape = ee1.Oriented(E.Orientation());
612 ee1 = TopoDS::Edge(aLocalShape);
613 // ee1 = TopoDS::Edge(ee1.Oriented(E.Orientation()));
614 if(counter == 1) theFV = TopExp::FirstVertex(ee1,Standard_True);
615 myLFMap(E).Append(ee1);
617 thePreviousEdge = ee1;
624 // Case of several edges
625 if(!FirstEdge.IsSame(LastEdge)) {
626 for(; EX1.More(); EX1.Next()) {
627 const TopoDS_Edge& E = EX1.Current();
628 if(!myLFMap.IsBound(E)) {
629 TopTools_ListOfShape thelist1;
630 myLFMap.Bind(E, thelist1);
634 if(!E.IsSame(LastEdge)) {
635 Handle(Geom_Curve) ccc = BRep_Tool::Curve(E, f, l);
636 TopoDS_Vertex v1, v2;
637 if(!thePreviousEdge.IsNull()) {
638 v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
639 v2 = TopExp::LastVertex(E,Standard_True);
642 // v1 = TopExp::LastVertex(E,Standard_True);
643 v1 = TopExp::FirstVertex(E,Standard_True);
644 v2 = TopExp::LastVertex(E,Standard_True);
646 BRepLib_MakeEdge E1(ccc, v1, v2);
647 TopoDS_Edge E11 = TopoDS::Edge(E1.Shape());
648 TopoDS_Shape aLocalShape = E11.Oriented(E.Orientation());
649 E11 = TopoDS::Edge(aLocalShape);
650 // E11 = TopoDS::Edge(E11.Oriented(E.Orientation()));
651 thePreviousEdge = E11;
652 myLFMap(E).Append(E11);
654 if(counter == 1) theFV = TopExp::FirstVertex(E11,Standard_True);
659 Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
660 gp_Pnt pf = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
661 gp_Pnt pl = myLastPnt;
663 if(thePreviousEdge.IsNull()) {
664 BRepLib_MakeEdge e(cc, pf , pl);
665 ee = TopoDS::Edge(e.Shape());
668 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
669 BRepLib_MakeVertex v2(pl);
670 BRepLib_MakeEdge e(cc, v1, v2);
671 ee = TopoDS::Edge(e.Shape());
673 TopoDS_Shape aLocalShape = ee.Oriented(E.Orientation());
674 ee = TopoDS::Edge(aLocalShape);
675 // ee = TopoDS::Edge(ee.Oriented(E.Orientation()));
677 myLFMap(E).Append(ee);
678 if(counter == 1) theFV = TopExp::FirstVertex(ee,Standard_True);
679 thePreviousEdge = ee;
686 TopTools_ListIteratorOfListOfShape it(myListOfEdges);
687 Standard_Boolean FirstOK = Standard_False;
688 Standard_Boolean LastOK = Standard_False;
690 gp_Pnt theLastPnt = myLastPnt;
691 Standard_Integer sens = 0;
692 TopoDS_Edge theEdge, theLEdge, theFEdge;
693 Standard_Integer counter1 = counter;
694 TopTools_ListOfShape NewListOfEdges;
695 NewListOfEdges.Clear();
697 const TopoDS_Edge& edg = TopoDS::Edge(it.Value());
700 Handle(Geom_Curve) ccc = BRep_Tool::Curve(edg, f, l);
701 Handle(Geom_TrimmedCurve) cc = new Geom_TrimmedCurve(ccc, f, l);
702 if ( edg.Orientation() == TopAbs_REVERSED) cc->Reverse();
704 fp = cc->Value(cc->FirstParameter());
705 lp = cc->Value(cc->LastParameter());
706 Standard_Real dist = fp.Distance(theLastPnt);
709 LastOK = Standard_True;
712 dist = lp.Distance(theLastPnt);
715 LastOK = Standard_True;
719 Standard_Integer FirstFlag = 0;
720 if(sens==1 && lp.Distance(myFirstPnt) <= myTol) {
721 FirstOK = Standard_True;
724 else if(sens==2 && fp.Distance(myFirstPnt) <= myTol) {
725 FirstOK = Standard_True;
731 Standard_Real fpar = cc->FirstParameter();
732 Standard_Real lpar = cc->LastParameter();
734 if(thePreviousEdge.IsNull()) {
735 BRepLib_MakeEdge e(cc, fpar, lpar);
736 eeee = TopoDS::Edge(e.Shape());
739 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
740 BRepLib_MakeVertex v2(cc->Value(lpar));
741 BRepLib_MakeEdge e(cc, v1, v2);
742 eeee = TopoDS::Edge(e.Shape());
746 if(thePreviousEdge.IsNull()) {
747 BRepLib_MakeVertex v1(cc->Value(fpar));
748 BRepLib_MakeEdge e(cc, v1, theFV);
749 eeee = TopoDS::Edge(e.Shape());
752 const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True);
753 BRepLib_MakeEdge e(cc, v1, theFV);
754 eeee = TopoDS::Edge(e.Shape());
758 thePreviousEdge = eeee;
760 if(counter == 1) theFV = TopExp::FirstVertex(eeee,Standard_True);
762 NewListOfEdges.Append(edg);
767 theLastPnt = BRep_Tool::Pnt(TopExp::LastVertex(theEdge,Standard_True));
773 else if(FirstFlag == 2) {
778 it.Initialize(myListOfEdges);
779 LastOK = Standard_False;
781 else if(it.More()) it.Next();
783 Sliding = Standard_False;
790 TopTools_DataMapOfShapeListOfShape SlidMap;
793 if(Sliding && counter1 > counter) {
794 TopTools_ListIteratorOfListOfShape it;
795 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm;
796 TopExp_Explorer EX2(w, TopAbs_EDGE);
797 Standard_Integer ii = 0;
798 for(; EX2.More(); EX2.Next()) {
799 const TopoDS_Edge& E = TopoDS::Edge(EX2.Current());
801 if(ii >= counter && ii <= counter1) {
802 it.Initialize(NewListOfEdges);
803 Standard_Integer jj = 0;
804 for(; it.More(); it.Next()) {
805 const TopoDS_Edge& e2 = TopoDS::Edge(it.Value());
807 if(jj== (ii - counter +1)) {
808 itm.Initialize(mySlface);
809 for(; itm.More(); itm.Next()) {
810 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
811 const TopTools_ListOfShape& ledg = itm.Value();
812 TopTools_ListIteratorOfListOfShape itedg(ledg);
813 //Standard_Integer iiii = 0;
814 for(; itedg.More(); itedg.Next()) {
815 const TopoDS_Edge& e1 = TopoDS::Edge(itedg.Value());
817 if(!SlidMap.IsBound(fac)) {
818 TopTools_ListOfShape thelist2;
819 SlidMap.Bind(fac, thelist2);
821 SlidMap(fac).Append(E);
835 // ---Arguments of LocOpe_LinearForm : arguments of the prism
839 BB.MakeFace(F, myPln, myTol);
847 // ---Case without sliding : construction of the face profile
851 if (Modify) cout << " Sliding failure" << endl;
852 cout << " no Sliding" << endl;
855 TopExp_Explorer explo1(BndFace, TopAbs_WIRE);
856 TopoDS_Wire WWW = TopoDS::Wire(explo1.Current());
857 BRepTools_WireExplorer explo(WWW);
861 TopoDS_Vertex NewV1, NewV2, LastV, v;
862 NewV1.Nullify(); NewV2.Nullify(); LastV.Nullify();
864 for(; explo.More(); explo.Next()) {
865 const TopoDS_Edge& e = TopoDS::Edge(explo.Current());
866 TopoDS_Vertex v1 = TopExp::FirstVertex(e,Standard_True);
867 TopoDS_Vertex v2 = TopExp::LastVertex(e,Standard_True);
869 Standard_Real f, l;//, t;
870 Handle(Geom_Curve) ln = BRep_Tool::Curve(e, f, l);
871 // Handle(Geom_Curve) lln = BRep_Tool::Curve(e, f, l);
872 // Handle(Geom_Curve) ln;
873 // if(e.Orientation() == TopAbs_REVERSED) {
874 // ln = Handle(Geom_Curve)::DownCast(lln->Reversed());
875 // v = v1; v1 = v2; v2= v;
876 // f = IntPar(ln, BRep_Tool::Pnt(v1));
877 // l = IntPar(ln, BRep_Tool::Pnt(v2));
881 Handle(Geom2d_Curve) l2d = GeomAPI::To2d(ln, Plane->Pln());
882 Geom2dAPI_InterCurveCurve intcc(l2d, ln2d, Precision::Confusion());
883 TopoDS_Vertex VV; VV.Nullify();
884 TopoDS_Edge ee1, ee2;
886 if(intcc.NbPoints() > 0) {
887 gp_Pnt2d P = intcc.Point(1);
889 myPln->D0(P.X(), P.Y(), point);
890 Standard_Real par = IntPar(ln, point);
891 if(f <= par && l >= par) {
892 Bu.MakeVertex(VV, point, Precision::Confusion());
896 if(VV.IsNull() && NewV1.IsNull()) continue;
898 if(!VV.IsNull() && NewV1.IsNull()) {
901 BRepLib_MakeEdge ee1(NewV1, LastV);
906 if(VV.IsNull() && !NewV1.IsNull()) {
907 BRepLib_MakeEdge ee1(LastV, v2);
913 if(!VV.IsNull() && !NewV1.IsNull()) {
915 BRepLib_MakeEdge ee1(LastV, NewV2);
918 BRepLib_MakeEdge ee2(LastV, NewV1);
924 BRepLib_MakeFace newbndface(myPln->Pln(), Wiwiwi, Standard_True);
925 TopoDS_Face NewBndFace = TopoDS::Face(newbndface.Shape());
927 BRepTopAdaptor_FClass2d Cl(NewBndFace, Precision::Confusion());
928 Standard_Real paru, parv;
929 ElSLib::Parameters(myPln->Pln(), CheckPnt, paru, parv);
930 gp_Pnt2d checkpnt2d(paru, parv);
931 if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) {
932 //modified by NIZNHY-PKV Fri Mar 22 16:52:52 2002 f
933 //BRepAlgo_Cut c(BndFace, NewBndFace);
934 BRepAlgoAPI_Cut c(BndFace, NewBndFace);
935 //modified by NIZNHY-PKV Fri Mar 22 16:52:57 2002 t
936 TopExp_Explorer exp(c.Shape(), TopAbs_WIRE);
937 const TopoDS_Wire& w = TopoDS::Wire(exp.Current());
938 // akm 13/02/02 : we know the plane. Why not to use it?
939 // BRepLib_MakeFace ff(w);
940 BRepLib_MakeFace ff(myPln->Pln(), w, Standard_True);
941 NewBndFace = TopoDS::Face(ff.Shape());
945 if(!BRepAlgo::IsValid(NewBndFace)) {
947 cout << "Invalid new bounding face" << endl;
949 myStatusError = BRepFeat_InvShape;
954 BndFace = NewBndFace;
958 Standard_Boolean ProfileOK;
959 ProfileOK = NoSlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,
960 bnd,BndFace,CheckPnt,
961 FirstFace,LastFace,FirstVertex,LastVertex,
962 FirstEdge,LastEdge,OnFirstFace,OnLastFace);
966 cout << "Not computable" << endl;
967 if (trc) cout << " Face profile not computable" << endl;
969 myStatusError = BRepFeat_NoFaceProf;
975 // ---Propagation on the faces of the initial shape
976 // to find the faces concerned by the rib
977 Standard_Boolean falseside = Standard_True;
978 Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
979 // Control if there is everything required to have the material at the proper side
980 if(falseside == Standard_False) {
982 cout << " Verify plane and wire orientation" << endl;
984 myStatusError = BRepFeat_FalseSide;
991 TopTools_ListIteratorOfListOfShape it;
992 it.Initialize(SliList);
997 BB.MakeShell(TopoDS::Shell(comp));
999 for(; it.More(); it.Next()) {
1000 BB.Add(comp, it.Value());
1009 mySliding = Sliding;
1011 TopExp_Explorer exp;
1012 for ( exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
1013 TopTools_ListOfShape thelist3;
1014 myMap.Bind(exp.Current(), thelist3);
1015 myMap(exp.Current()).Append(exp.Current());
1021 //=======================================================================
1023 //purpose : add elements of gluing
1024 //=======================================================================
1026 void BRepFeat_MakeRevolutionForm::Add(const TopoDS_Edge& E,
1027 const TopoDS_Face& F)
1030 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1031 if (trc) cout << "BRepFeat_MakeRevolutionForm::Add" << endl;
1033 if(mySlface.IsEmpty()) {
1034 TopExp_Explorer exp;
1035 for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) {
1036 if (exp.Current().IsSame(F)) {
1041 Standard_ConstructionError::Raise();
1044 if (!mySlface.IsBound(F)) {
1045 TopTools_ListOfShape thelist;
1046 mySlface.Bind(F, thelist);
1048 TopTools_ListIteratorOfListOfShape itl(mySlface(F));
1049 for (; itl.More();itl.Next()) {
1050 if (itl.Value().IsSame(E)) {
1055 mySlface(F).Append(E);
1062 //=======================================================================
1063 //function : Perform
1064 //purpose : construction
1065 //=======================================================================
1067 void BRepFeat_MakeRevolutionForm::Perform()
1070 Standard_Boolean trc = BRepFeat_GettraceFEAT();
1071 if (trc) cout << "BRepFeat_MakeRevolutionForm::Perform()" << endl;
1073 if(mySbase.IsNull() || mySkface.IsNull() || myPbase.IsNull()) {
1075 if (trc) cout << " Fields not initialized" << endl;
1077 myStatusError = BRepFeat_NotInitialized;
1084 TopExp_Explorer exx(myPbase, TopAbs_VERTEX);
1085 for(; exx.More(); exx.Next()) {
1086 const TopoDS_Vertex& vv = TopoDS::Vertex(exx.Current());
1088 Pt = BRep_Tool::Pnt(vv);
1095 T.SetRotation(myAxe, -myAngle2);
1096 BRepBuilderAPI_Transform trsf(T);
1097 trsf.Perform(myPbase, Standard_False);
1098 TopoDS_Face Pbase = TopoDS::Face(trsf.Shape());
1099 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter(myLFMap);
1100 for(; iter.More(); iter.Next()) {
1101 const TopoDS_Shape& e1 = iter.Value().First();
1102 TopExp_Explorer ex1(myPbase, TopAbs_EDGE);
1103 TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
1104 for(; ex1.More(); ex1.Next()) {
1105 if(ex1.Current().IsSame(e1)) {
1106 myLFMap(iter.Key()).Clear();
1107 myLFMap(iter.Key()).Append(ex2.Current());
1113 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter1(mySlface);
1114 for(; iter1.More(); iter1.Next()) {
1115 const TopoDS_Shape& f1 = iter1.Key();
1116 const TopoDS_Shape& e1 = iter1.Value().First();
1117 TopExp_Explorer ex1(myPbase, TopAbs_EDGE);
1118 TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
1119 for(; ex1.More(); ex1.Next()) {
1120 const TopoDS_Shape& E1 = ex1.Current();
1121 const TopoDS_Shape& E2 = ex2.Current();
1123 mySlface(f1).Clear();
1124 mySlface(f1).Append(E2);
1130 trsf.Perform(mySkface, Standard_False);
1131 // flo : check if it is required to reattributr the field mySkface
1132 // TopoDS_Face mySkface = TopoDS::Face(trsf.Shape());
1133 mySkface = TopoDS::Face(trsf.Shape());
1136 LocOpe_RevolutionForm theForm;
1137 theForm.Perform(myPbase, myAxe, (myAngle1+myAngle2));
1138 TopoDS_Shape VraiForm = theForm.Shape(); // uncut primitive
1140 // management of descendants
1141 MajMap(myPbase,theForm,myMap,myFShape,myLShape);
1147 gp_Pln Pln0 = myPln->Pln();
1148 BRepLib_MakeFace f(Pln0);
1151 gp_Vec vec1 = myHeight1*Normal(f, Pt);
1152 gp_Vec vec2 = -myHeight2*Normal(f, Pt);
1154 gp_Pln Pln1 = Pln0.Translated(vec1);
1155 gp_Pln Pln2 = Pln0.Translated(vec2);
1157 BRepLib_MakeFace ff1(Pln1);
1158 BRepLib_MakeFace ff2(Pln2);
1159 TopoDS_Face f1 = TopoDS::Face(ff1.Shape());
1160 TopoDS_Face f2 = TopoDS::Face(ff2.Shape());
1161 BRepFeat::FaceUntil(mySbase, f1);
1162 BRepFeat::FaceUntil(mySbase, f2);
1164 LocOpe_CSIntersector ASI1(f1);
1165 LocOpe_CSIntersector ASI2(f2);
1167 Handle(Geom_Line) normale = new Geom_Line(Pt, vec1);
1168 TColGeom_SequenceOfCurve scur;
1169 scur.Append(normale);
1174 if(!ASI1.IsDone() || !ASI2.IsDone() ||
1175 ASI1.NbPoints(1) != 1 || ASI2.NbPoints(1) != 1) {
1177 if (trc) cout << " Intersection failure" << endl;
1179 myStatusError = BRepFeat_BadIntersect;
1184 TopAbs_Orientation Ori1 = ASI1.Point(1,1).Orientation();
1185 TopAbs_Orientation Ori2 = TopAbs::Reverse(ASI2.Point(1,1).Orientation());
1186 TopoDS_Face FF1 = ASI1.Point(1,1).Face();
1187 TopoDS_Face FF2 = ASI2.Point(1,1).Face();
1191 B.MakeCompound(TopoDS::Compound(Comp));
1192 TopoDS_Solid S1 = BRepFeat::Tool(f1,FF1,Ori1);
1193 TopoDS_Solid S2 = BRepFeat::Tool(f2,FF2,Ori2);
1194 if (!S1.IsNull()) B.Add(Comp,S1);
1195 if (!S2.IsNull()) B.Add(Comp,S2);
1197 //modified by NIZNHY-PKV Fri Mar 22 16:53:20 2002 f
1198 //BRepAlgo_Cut trP(VraiForm,Comp);
1199 BRepAlgoAPI_Cut trP(VraiForm,Comp);
1200 //modified by NIZNHY-PKV Fri Mar 22 16:53:23 2002 t
1201 // coupe de la nervure par deux plans parallels
1202 TopTools_DataMapOfShapeListOfShape SlidingMap;
1204 // management of descendants
1206 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape it1;
1207 it1.Initialize(myMap);
1208 for(; it1.More(); it1.Next()) {
1209 const TopoDS_Shape& orig = it1.Key();
1210 if(it1.Value().IsEmpty()) continue;
1211 const TopoDS_Shape& sh = it1.Value().First();
1212 exx.Init(VraiForm, TopAbs_FACE);
1213 for(; exx.More(); exx.Next()) {
1214 const TopoDS_Face& fac = TopoDS::Face(exx.Current());
1215 TopExp_Explorer exx1(fac, TopAbs_WIRE);
1216 const TopoDS_Wire& thew = TopoDS::Wire(exx1.Current());
1217 if(thew.IsSame(myFShape)) {
1218 const TopTools_ListOfShape& desfaces = trP.Modified(f2);
1219 myMap(myFShape) = desfaces;
1222 else if(thew.IsSame(myLShape)) {
1223 const TopTools_ListOfShape& desfaces = trP.Modified(f1);
1224 myMap(myLShape) = desfaces;
1227 if(fac.IsSame(sh)) {
1228 if (trP.IsDeleted(fac)) {
1231 const TopTools_ListOfShape& desfaces = trP.Modified(fac);
1232 if(!desfaces.IsEmpty()) {
1233 myMap(orig).Clear();
1234 myMap(orig) = trP.Modified(fac);
1241 exx.Init(VraiForm, TopAbs_FACE);
1242 for(; exx.More(); exx.Next()) {
1243 const TopoDS_Face& fac = TopoDS::Face(exx.Current());
1244 TopTools_ListOfShape thelist;
1245 SlidingMap.Bind(fac, thelist);
1246 if (trP.IsDeleted(fac)) {
1249 const TopTools_ListOfShape& desfaces = trP.Modified(fac);
1250 if(!desfaces.IsEmpty())
1251 SlidingMap(fac) = desfaces;
1253 SlidingMap(fac).Append(fac);
1258 // gestion of faces of sliding
1259 SetGluedFaces(mySlface, theForm, SlidingMap, myGluedF);
1261 VraiForm = trP.Shape(); // primitive cut
1263 if(!myGluedF.IsEmpty())
1264 myPerfSelection = BRepFeat_NoSelection;
1266 myPerfSelection = BRepFeat_SelectionSh;
1268 exx.Init(myPbase, TopAbs_EDGE);
1269 for(; exx.More(); exx.Next()) {
1270 const TopoDS_Edge& e = TopoDS::Edge(exx.Current());
1271 if(!myMap.IsBound(e)) {
1273 if (trc) cout << " Sliding face not in Base shape" << endl;
1275 myStatusError = BRepFeat_IncSlidFace;
1281 myGShape = VraiForm;
1283 if(!myGluedF.IsEmpty() && !mySUntil.IsNull()) {
1285 cout << "The case is not computable" << endl;
1286 if (trc) cout << " Glued faces not empty and Until shape not null" << endl;
1288 myStatusError = BRepFeat_InvShape;
1293 LFPerform(); // topological reconstruction
1297 //=======================================================================
1298 //function : Propagate
1299 //purpose : propagation on the faces of the inital shape, find faces
1300 // concerned by the rib
1301 //=======================================================================
1303 Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& SliList,
1304 const TopoDS_Face& fac,
1305 const gp_Pnt& Firstpnt,
1306 const gp_Pnt& Lastpnt,
1307 Standard_Boolean& falseside)
1310 Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
1311 if (trc) cout << "BRepFeat_MakeRevolutionForm::Propagate" << endl;
1313 gp_Pnt Firstpoint = Firstpnt;
1314 gp_Pnt Lastpoint = Lastpnt;
1316 Standard_Boolean result = Standard_True;
1317 TopoDS_Face CurrentFace, saveFace;
1318 CurrentFace = TopoDS::Face(SliList.First());
1319 saveFace = CurrentFace;
1320 // BRepBuilderAPI_MakeFace fac(myPln);
1321 Standard_Boolean LastOK = Standard_False, FirstOK= Standard_False;
1322 TopoDS_Vertex v1, v2, v3, v4, Vert;
1323 //modified by NIZNHY-PKV Fri Mar 22 16:54:09 2002 f
1324 //BRepAlgo_Section sect (fac, CurrentFace, Standard_False);
1325 BRepAlgoAPI_Section sect (fac, CurrentFace, Standard_False);
1326 //modified by NIZNHY-PKV Fri Mar 22 16:54:14 2002 t
1327 sect.Approximation(Standard_True);
1332 Standard_Integer ii = 0;
1333 for (Ex.Init(sect.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1336 e = TopoDS::Edge(Ex.Current());
1339 e1 = TopoDS::Edge(Ex.Current());
1344 falseside = Standard_False;
1345 return Standard_False;
1348 //modified by NIZNHY-PKV Tue Apr 2 15:08:23 2002 f
1350 Standard_Real aTolV1, aTolV2;
1351 myListOfEdges.Clear();
1352 TopTools_ListOfShape thelist;
1353 mySlface.Bind(CurrentFace, thelist);
1354 mySlface(CurrentFace).Append(e1);
1356 myListOfEdges.Append(e1);
1358 v1 = TopExp::FirstVertex(e1,Standard_True);
1359 v2 = TopExp::LastVertex (e1,Standard_True);
1361 FP = BRep_Tool::Pnt(v1);
1362 LP = BRep_Tool::Pnt(v2);
1364 aTolV1=BRep_Tool::Tolerance(v1);
1365 aTolV2=BRep_Tool::Tolerance(v2);
1367 if(FP.Distance(Firstpoint) <= aTolV1 ||
1368 FP.Distance(Lastpoint) <= aTolV1) {
1369 FirstOK = Standard_True;
1371 if(LP.Distance(Firstpoint)<= aTolV2 ||
1372 LP.Distance(Lastpoint) <= aTolV2) {
1373 LastOK = Standard_True;
1376 if(LastOK && FirstOK) {
1381 myListOfEdges.Clear();
1384 //modified by NIZNHY-PKV Tue Apr 2 15:08:26 2002 t
1387 myListOfEdges.Clear();
1388 TopTools_ListOfShape thelist1;
1389 mySlface.Bind(CurrentFace, thelist1);
1390 mySlface(CurrentFace).Append(e);
1392 myListOfEdges.Append(e);
1394 // mySlface.Bind(CurrentFace,TopTools_ListOfShape());
1395 mySlface(CurrentFace).Append(e1);
1396 // myListOfEdges.Append(e1);
1398 v1 = TopExp::FirstVertex(e,Standard_True);
1399 v2 = TopExp::LastVertex(e,Standard_True);
1400 v3 = TopExp::FirstVertex(e1,Standard_True);
1401 v4 = TopExp::LastVertex(e1,Standard_True);
1402 gp_Pnt p1, p2, p3, p4;
1403 p1 = BRep_Tool::Pnt(v1); FP = p1;
1404 p2 = BRep_Tool::Pnt(v2); LP = p2;
1405 p3 = BRep_Tool::Pnt(v3);
1406 p4 = BRep_Tool::Pnt(v4);
1407 if(p1.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)) {
1408 if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) {
1409 FirstOK = Standard_True;
1412 else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) {
1413 FirstOK = Standard_True;
1420 else if(p1.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1421 if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) {
1422 FirstOK = Standard_True;
1425 else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) {
1426 FirstOK = Standard_True;
1433 else if(p2.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)) {
1434 if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) {
1435 LastOK = Standard_True;
1438 else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) {
1439 LastOK = Standard_True;
1446 else if(p2.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1447 if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) {
1448 LastOK = Standard_True;
1451 else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) {
1452 LastOK = Standard_True;
1465 myListOfEdges.Clear();
1466 TopTools_ListOfShape thelist2;
1467 mySlface.Bind(CurrentFace, thelist2);
1468 mySlface(CurrentFace).Append(e);
1470 myListOfEdges.Append(e);
1472 v1 = TopExp::FirstVertex(e,Standard_True);
1473 v2 = TopExp::LastVertex(e,Standard_True);
1475 FP = BRep_Tool::Pnt(v1);
1476 LP = BRep_Tool::Pnt(v2);
1478 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)
1479 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1480 FirstOK = Standard_True;
1482 if(LP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)
1483 || LP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1484 LastOK = Standard_True;
1487 if(LastOK && FirstOK) {
1492 TopTools_IndexedDataMapOfShapeListOfShape mapedges;
1493 TopExp::MapShapesAndAncestors(mySbase, TopAbs_EDGE, TopAbs_FACE, mapedges);
1495 TopoDS_Edge FirstEdge;
1497 TopoDS_Vertex Vprevious; Vprevious.Nullify();
1498 TopoDS_Vertex Vpreprevious; Vpreprevious.Nullify();
1501 // find edge connected to v1:
1503 if(!v1.IsNull()) pt= BRep_Tool::Pnt(v1);
1505 if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious);
1507 if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious);
1509 if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) ||
1510 (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) {
1511 falseside = Standard_False;
1512 return Standard_False;
1515 for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1516 const TopoDS_Edge& e = TopoDS::Edge(ex.Current());
1518 BRepExtrema_ExtPC projF(v1, e);
1520 if(projF.IsDone() && projF.NbExt() >=1) {
1521 Standard_Real dist2min = RealLast();
1522 Standard_Integer index = 0;
1523 for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) {
1524 if (projF.SquareDistance(sol) <= dist2min) {
1526 dist2min = projF.SquareDistance(sol);
1530 if (dist2min <= BRep_Tool::Tolerance(e) * BRep_Tool::Tolerance(e)) {
1538 const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1539 TopTools_ListIteratorOfListOfShape It(L);
1541 for (; It.More(); It.Next()) {
1542 const TopoDS_Face& FF = TopoDS::Face(It.Value());
1543 if (!FF.IsSame(CurrentFace)) {
1549 //modified by NIZNHY-PKV Fri Mar 22 16:54:28 2002 f
1550 //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False);
1551 BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False);
1552 //modified by NIZNHY-PKV Fri Mar 22 16:54:33 2002 t
1553 sectf.Approximation(Standard_True);
1557 for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1558 edg1 = TopoDS::Edge(Ex.Current());
1559 gp_Pnt ppp1 = BRep_Tool::Pnt(TopExp::FirstVertex(edg1,Standard_True));
1560 gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg1,Standard_True));
1561 if(ppp1.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1) ||
1562 ppp2.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1))
1566 TopTools_ListOfShape thelist3;
1567 mySlface.Bind(CurrentFace, thelist3);
1568 mySlface(CurrentFace).Append(edg1);
1569 myListOfEdges.Append(edg1);
1571 if (!edg1.IsNull()) SliList.Prepend(CurrentFace);
1572 else return Standard_False;
1574 Vert = TopExp::FirstVertex(edg1,Standard_True);
1575 gp_Pnt PP = BRep_Tool::Pnt(Vert);
1576 FP = BRep_Tool::Pnt(v1);
1577 Standard_Real tol = BRep_Tool::Tolerance(edg1);
1578 Standard_Real tol1 = BRep_Tool::Tolerance(v1);
1579 if(tol1 > tol) tol = tol1;
1580 Standard_Real dist = PP.Distance(FP);
1582 Vpreprevious = Vprevious;
1584 v1 = TopExp::LastVertex(edg1,Standard_True);
1587 Vpreprevious = Vprevious;
1592 FP = BRep_Tool::Pnt(v1);
1594 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)
1595 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) {
1596 FirstOK = Standard_True;
1600 CurrentFace = saveFace;
1601 Vprevious.Nullify();
1602 Vpreprevious.Nullify();
1605 // find edge connected to v2:
1607 if(!v2.IsNull()) pt= BRep_Tool::Pnt(v2);
1609 if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious);
1611 if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious);
1613 if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) ||
1614 (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) {
1615 falseside = Standard_False;
1616 return Standard_False;
1619 for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) {
1620 const TopoDS_Edge& e = TopoDS::Edge(ex.Current());
1621 BRepExtrema_ExtPC projF(v2, e);
1623 if(projF.IsDone() && projF.NbExt() >=1) {
1624 Standard_Real dist2min = RealLast();
1625 Standard_Integer index = 0;
1626 for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) {
1627 if (projF.SquareDistance(sol) <= dist2min) {
1629 dist2min = projF.SquareDistance(sol);
1633 if (dist2min <= BRep_Tool::Tolerance(e) * BRep_Tool::Tolerance(e)) {
1641 const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge);
1642 TopTools_ListIteratorOfListOfShape It(L);
1644 for (; It.More(); It.Next()) {
1645 const TopoDS_Face& FF = TopoDS::Face(It.Value());
1646 if (!FF.IsSame(CurrentFace)) {
1654 //modified by NIZNHY-PKV Fri Mar 22 16:54:45 2002 f
1655 //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False);
1656 BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False);
1657 //modified by NIZNHY-PKV Fri Mar 22 16:54:52 2002 t
1658 sectf.Approximation(Standard_True);
1662 for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) {
1663 edg2 = TopoDS::Edge(Ex.Current());
1664 gp_Pnt ppp1 = BRep_Tool::Pnt(TopExp::FirstVertex(edg2,Standard_True));
1665 gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg2,Standard_True));
1666 if(ppp1.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2) ||
1667 ppp2.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2))
1670 TopTools_ListOfShape thelist4;
1671 mySlface.Bind(CurrentFace, thelist4);
1672 mySlface(CurrentFace).Append(edg2);
1673 myListOfEdges.Append(edg2);
1675 if (!edg2.IsNull()) SliList.Append(CurrentFace);
1676 else return Standard_False;
1678 Vert = TopExp::FirstVertex(edg2,Standard_True);
1679 gp_Pnt PP = BRep_Tool::Pnt(Vert);
1680 FP = BRep_Tool::Pnt(v2);
1681 if (PP.Distance(FP)<= BRep_Tool::Tolerance(v2)) {
1682 Vpreprevious = Vprevious;
1684 v2 = TopExp::LastVertex(edg2,Standard_True);
1689 FP = BRep_Tool::Pnt(v2);
1692 if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)
1693 || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) {
1694 LastOK = Standard_True;
1697 if(!e1.IsNull()) myListOfEdges.Append(e1);
1703 //=======================================================================
1705 //purpose : management of descendants
1706 //=======================================================================
1708 static void MajMap(const TopoDS_Shape& theB,
1709 const LocOpe_RevolutionForm& theP,
1710 TopTools_DataMapOfShapeListOfShape& theMap, // myMap
1711 TopoDS_Shape& theFShape, // myFShape
1712 TopoDS_Shape& theLShape) // myLShape
1714 TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE);
1716 theFShape = exp.Current();
1717 TopTools_ListOfShape thelist;
1718 theMap.Bind(theFShape, thelist);
1719 for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) {
1720 const TopoDS_Shape& sh = exp.Current();
1721 theMap(theFShape).Append(sh);
1725 exp.Init(theP.LastShape(),TopAbs_WIRE);
1727 theLShape = exp.Current();
1728 TopTools_ListOfShape thelist1;
1729 theMap.Bind(theLShape, thelist1);
1730 for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) {
1731 const TopoDS_Shape& sh = exp.Current();
1732 theMap(theLShape).Append(sh);
1736 for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
1737 if (!theMap.IsBound(exp.Current())) {
1738 TopTools_ListOfShape thelist2;
1739 theMap.Bind(exp.Current(), thelist2);
1740 theMap(exp.Current()) = theP.Shapes(exp.Current());
1746 //=======================================================================
1747 //function : SetGluedFaces
1748 //purpose : managemnet of sliding faces
1749 //=======================================================================
1751 static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
1752 LocOpe_RevolutionForm& thePrism,
1753 const TopTools_DataMapOfShapeListOfShape& SlidingMap,
1754 TopTools_DataMapOfShapeShape& theMap)
1757 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap);
1758 if(!theSlmap.IsEmpty()) {
1759 for (; itm.More(); itm.Next()) {
1760 const TopoDS_Face& fac = TopoDS::Face(itm.Key());
1761 const TopTools_ListOfShape& ledg = itm.Value();
1762 TopTools_ListIteratorOfListOfShape it;
1763 for (it.Initialize(ledg); it.More(); it.Next()) {
1764 const TopTools_ListOfShape& gfac = thePrism.Shapes(it.Value());
1765 if (gfac.Extent() != 1) {
1767 cout << "Pb SetGluedFace" << endl;
1770 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iterm(SlidingMap);
1771 for(; iterm.More(); iterm.Next()) {
1772 const TopoDS_Face& ff = TopoDS::Face(iterm.Key());
1773 const TopTools_ListOfShape& lfaces = iterm.Value();
1774 if(lfaces.IsEmpty()) continue;
1775 const TopoDS_Face& fff = TopoDS::Face(lfaces.First());
1776 if(gfac.First().IsSame(ff)) theMap.Bind(fff,fac);