1 // File: BRepSweep_Rotation.cxx
2 // Created: Mon Feb 15 17:48:39 1993
3 // Author: Laurent BOURESCHE
6 #include <BRepSweep_Rotation.ixx>
7 #include <BRepTools_Quilt.hxx>
8 #include <BRepAdaptor_Curve.hxx>
9 #include <BRepAdaptor_Surface.hxx>
10 #include <BRep_Tool.hxx>
11 #include <BRepTools.hxx>
13 #include <TopoDS_Shape.hxx>
14 #include <TopoDS_Vertex.hxx>
18 #include <GeomAdaptor_Curve.hxx>
19 #include <GeomAdaptor_Surface.hxx>
20 #include <Adaptor3d_SurfaceOfRevolution.hxx>
21 #include <Geom_SurfaceOfRevolution.hxx>
22 #include <Geom_CylindricalSurface.hxx>
23 #include <Geom_ConicalSurface.hxx>
24 #include <Geom_SphericalSurface.hxx>
25 #include <Geom_ToroidalSurface.hxx>
26 #include <Geom_Plane.hxx>
27 #include <Geom_Circle.hxx>
28 #include <Geom_Line.hxx>
29 #include <Geom2d_Circle.hxx>
30 #include <Geom2d_Line.hxx>
32 #include <gp_Trsf.hxx>
33 #include <gp_Circ2d.hxx>
35 #include <gp_Dir2d.hxx>
37 #include <gp_Lin2d.hxx>
39 #include <gp_Pnt2d.hxx>
40 #include <gp_Ax22d.hxx>
41 #include <gp_Cylinder.hxx>
43 #include <gp_Cone.hxx>
44 #include <gp_Sphere.hxx>
45 #include <gp_Torus.hxx>
47 #include <Precision.hxx>
48 #include <Standard_ConstructionError.hxx>
50 #include <GeomAdaptor_HCurve.hxx>
51 #include <Geom_TrimmedCurve.hxx>
53 static Standard_Real ComputeTolerance(TopoDS_Edge& E,
55 const Handle(Geom2d_Curve)& C)
58 if(BRep_Tool::Degenerated(E)) return BRep_Tool::Tolerance(E);
60 Standard_Real first,last;
62 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);
63 Handle(Geom_Curve) c3d = BRep_Tool::Curve(E,first,last);
65 Standard_Real d2 = 0.;
66 Standard_Integer nn = 23;
67 Standard_Real unsurnn = 1./nn;
68 for(Standard_Integer i = 0; i <= nn; i++){
69 Standard_Real t = unsurnn*i;
70 Standard_Real u = first*(1.-t) + last*t;
71 gp_Pnt Pc3d = c3d->Value(u);
72 gp_Pnt2d UV = C->Value(u);
73 gp_Pnt Pcons = surf->Value(UV.X(),UV.Y());
74 if (Precision::IsInfinite(Pcons.X()) ||
75 Precision::IsInfinite(Pcons.Y()) ||
76 Precision::IsInfinite(Pcons.Z())) {
77 d2=Precision::Infinite();
80 Standard_Real temp = Pc3d.SquareDistance(Pcons);
81 if(temp > d2) d2 = temp;
84 if(d2<1.e-7) d2 = 1.e-7;
88 static void SetThePCurve(const BRep_Builder& B,
91 const TopAbs_Orientation O,
92 const Handle(Geom2d_Curve)& C)
94 // check if there is already a pcurve
96 Handle(Geom2d_Curve) OC;
98 Handle(Geom_Plane) GP = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(F,SL));
100 OC = BRep_Tool::CurveOnSurface(E,F,f,l);
102 B.UpdateEdge(E,C,F,ComputeTolerance(E,F,C));
104 if (O == TopAbs_REVERSED)
105 B.UpdateEdge(E,OC,C,F,ComputeTolerance(E,F,C));
107 B.UpdateEdge(E,C,OC,F,ComputeTolerance(E,F,C));
111 //=======================================================================
112 //function : BRepSweep_Rotation
114 //=======================================================================
116 BRepSweep_Rotation::BRepSweep_Rotation(const TopoDS_Shape& S,
117 const Sweep_NumShape& N,
118 const TopLoc_Location& L,
120 const Standard_Real D,
121 const Standard_Boolean C):
122 BRepSweep_Trsf(BRep_Builder(),S,N,L,C),
127 Standard_ConstructionError_Raise_if(D < Precision::Angular(),
128 "BRepSweep_Rotation::Constructor");
133 //=======================================================================
134 //function : MakeEmptyVertex
136 //=======================================================================
138 TopoDS_Shape BRepSweep_Rotation::MakeEmptyVertex
139 (const TopoDS_Shape& aGenV,
140 const Sweep_NumShape& aDirV)
142 //call only in construction mode with copy.
143 Standard_ConstructionError_Raise_if
144 (!myCopy,"BRepSweep_Translation::MakeEmptyVertex");
145 gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aGenV));
147 if (aDirV.Index()==2) P.Transform(myLocation.Transformation());
148 ////// modified by jgv, 1.10.01, for buc61005 //////
149 //myBuilder.Builder().MakeVertex(V,P,Precision::Confusion());
150 myBuilder.Builder().MakeVertex( V, P, BRep_Tool::Tolerance(TopoDS::Vertex(aGenV)) );
151 ////////////////////////////////////////////////////
152 if (aDirV.Index() == 1 &&
153 IsInvariant(aGenV) &&
154 myDirShapeTool.NbShapes() == 3) {
155 myBuiltShapes(myGenShapeTool.Index(aGenV),3) = Standard_True;
156 myShapes(myGenShapeTool.Index(aGenV),3) = V;
162 //=======================================================================
163 //function : MakeEmptyDirectingEdge
165 //=======================================================================
167 TopoDS_Shape BRepSweep_Rotation::MakeEmptyDirectingEdge
168 (const TopoDS_Shape& aGenV,
169 const Sweep_NumShape&)
172 gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aGenV));
173 gp_Dir Dirz(myAxe.Direction());
175 gp_Pnt O(myAxe.Location());
176 O.Translate(V.Dot(gp_Vec(O,P)) * V);
177 if (O.IsEqual(P,Precision::Confusion())) {
178 // make a degenerated edge
179 // temporary make 3D curve null so that
180 // parameters should be registered.
181 // myBuilder.Builder().MakeEdge(E);
183 Handle(Geom_Circle) GC = new Geom_Circle(Axis,0.);
185 MakeEdge(E,GC,BRep_Tool::Tolerance(TopoDS::Vertex(aGenV)));
186 myBuilder.Builder().Degenerated(E,Standard_True);
189 gp_Ax2 Axis(O,Dirz,gp_Dir(gp_Vec(O,P)));
190 Handle(Geom_Circle) GC = new Geom_Circle(Axis,O.Distance(P));
191 Standard_Real tol = BRep_Tool::Tolerance(TopoDS::Vertex(aGenV));
192 myBuilder.Builder().MakeEdge(E, GC, tol);
194 gp_Pnt PLast = GC->Value(myAng);
195 if(PLast.SquareDistance(P) > tol*tol) E.Closed(Standard_False);
205 //=======================================================================
206 //function : MakeEmptyGeneratingEdge
208 //=======================================================================
210 TopoDS_Shape BRepSweep_Rotation::MakeEmptyGeneratingEdge
211 (const TopoDS_Shape& aGenE,
212 const Sweep_NumShape& aDirV)
214 //call in case of construction with copy, or only when meridian touches myaxe.
215 Standard_Real First,Last;
217 Handle(Geom_Curve) C = Handle(Geom_Curve)::DownCast
218 (BRep_Tool::Curve(TopoDS::Edge(aGenE),Loc,First,Last)->Copy());
219 C->Transform(Loc.Transformation());
221 if(aDirV.Index() == 2) C->Transform(myLocation.Transformation());
222 myBuilder.Builder().MakeEdge(E,C,BRep_Tool::Tolerance(TopoDS::Edge(aGenE)));
223 if (aDirV.Index() == 1 &&
224 IsInvariant(aGenE) &&
225 myDirShapeTool.NbShapes() == 3) {
226 myBuiltShapes(myGenShapeTool.Index(aGenE),3) = Standard_True;
227 myShapes(myGenShapeTool.Index(aGenE),3) = E;
233 //=======================================================================
234 //function : SetParameters
236 //=======================================================================
238 void BRepSweep_Rotation::SetParameters
239 (const TopoDS_Shape& aNewFace,
240 TopoDS_Shape& aNewVertex,
241 const TopoDS_Shape& aGenF,
242 const TopoDS_Shape& aGenV,
243 const Sweep_NumShape&)
245 //Glue the parameter of vertices directly included in cap faces.
246 gp_Pnt2d pnt2d = BRep_Tool::Parameters(TopoDS::Vertex(aGenV),
247 TopoDS::Face(aGenF));
248 myBuilder.Builder().UpdateVertex
249 (TopoDS::Vertex(aNewVertex),pnt2d.X(),pnt2d.Y(),
250 TopoDS::Face(aNewFace),Precision::PConfusion());
253 //=======================================================================
254 //function : SetDirectingParameter
256 //=======================================================================
258 void BRepSweep_Rotation::SetDirectingParameter
259 (const TopoDS_Shape& aNewEdge,
260 TopoDS_Shape& aNewVertex,
262 const Sweep_NumShape&,
263 const Sweep_NumShape& aDirV)
265 Standard_Real param = 0;
266 TopAbs_Orientation ori = TopAbs_FORWARD;
267 if (aDirV.Index() == 2) {
269 ori = TopAbs_REVERSED;
271 TopoDS_Vertex V_wnt = TopoDS::Vertex(aNewVertex);
272 V_wnt.Orientation(ori);
273 myBuilder.Builder().UpdateVertex(V_wnt,
274 param,TopoDS::Edge(aNewEdge),
275 Precision::PConfusion());
279 //=======================================================================
280 //function : SetGeneratingParameter
282 //=======================================================================
284 void BRepSweep_Rotation::SetGeneratingParameter
285 (const TopoDS_Shape& aNewEdge,
286 TopoDS_Shape& aNewVertex,
287 const TopoDS_Shape& aGenE,
288 const TopoDS_Shape& aGenV,
289 const Sweep_NumShape&)
291 TopoDS_Vertex vbid = TopoDS::Vertex(aNewVertex);
292 vbid.Orientation(aGenV.Orientation());
293 myBuilder.Builder().UpdateVertex
295 BRep_Tool::Parameter(TopoDS::Vertex(aGenV),TopoDS::Edge(aGenE)),
296 TopoDS::Edge(aNewEdge),Precision::PConfusion());
300 //=======================================================================
301 //function : MakeEmptyFace
303 //=======================================================================
305 TopoDS_Shape BRepSweep_Rotation::MakeEmptyFace
306 (const TopoDS_Shape& aGenS,
307 const Sweep_NumShape& aDirS)
311 Handle(Geom_Surface) S;
312 if(aGenS.ShapeType()==TopAbs_EDGE){
314 Standard_Real First,Last;
315 Handle(Geom_Curve) C = BRep_Tool::Curve(TopoDS::Edge(aGenS),L,First,Last);
316 toler = BRep_Tool::Tolerance(TopoDS::Edge(aGenS));
317 gp_Trsf Tr = L.Transformation();
318 C = Handle(Geom_Curve)::DownCast(C->Copy());
319 //// modified by jgv, 9.12.03 ////
320 C = new Geom_TrimmedCurve( C, First, Last );
321 //////////////////////////////////
324 Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve();
325 HC->ChangeCurve().Load(C,First,Last);
326 Adaptor3d_SurfaceOfRevolution AS(HC,myAxe);
327 switch(AS.GetType()){
330 Handle(Geom_Plane) Pl = new Geom_Plane(AS.Plane());
334 case GeomAbs_Cylinder :
337 gp_Cylinder c = AS.Cylinder();
338 gp_Ax3 b = AS.Axis();
339 gp_Ax3 a = c.Position();
341 Handle(Geom_CylindricalSurface) Cy =
342 new Geom_CylindricalSurface(AS.Cylinder());
346 case GeomAbs_Sphere :
348 Handle(Geom_SphericalSurface) Sp =
349 new Geom_SphericalSurface(AS.Sphere());
355 Handle(Geom_ConicalSurface) Co =
356 new Geom_ConicalSurface(AS.Cone());
362 Handle(Geom_ToroidalSurface) To =
363 new Geom_ToroidalSurface(AS.Torus());
369 Handle(Geom_SurfaceOfRevolution) Se =
370 new Geom_SurfaceOfRevolution(C,myAxe);
378 S = BRep_Tool::Surface(TopoDS::Face(aGenS),L);
379 toler = BRep_Tool::Tolerance(TopoDS::Face(aGenS));
380 gp_Trsf Tr = L.Transformation();
381 S = Handle(Geom_Surface)::DownCast(S->Copy());
383 if (aDirS.Index()==2) S->Transform(myLocation.Transformation());
385 myBuilder.Builder().MakeFace(F,S,toler);
390 //=======================================================================
391 //function : SetPCurve
393 //=======================================================================
395 void BRepSweep_Rotation::SetPCurve
396 (const TopoDS_Shape& aNewFace,
397 TopoDS_Shape& aNewEdge,
398 const TopoDS_Shape& aGenF,
399 const TopoDS_Shape& aGenE,
400 const Sweep_NumShape&,
401 const TopAbs_Orientation orien)
403 //Set on edges of cap faces the same pcurves as
404 //on edges of the generator face.
405 Standard_Real First,Last;
406 SetThePCurve(myBuilder.Builder(),
407 TopoDS::Edge(aNewEdge),
408 TopoDS::Face(aNewFace),
410 BRep_Tool::CurveOnSurface
411 (TopoDS::Edge(aGenE),TopoDS::Face(aGenF),First,Last));
415 //=======================================================================
416 //function : SetGeneratingPCurve
418 //=======================================================================
420 void BRepSweep_Rotation::SetGeneratingPCurve
421 (const TopoDS_Shape& aNewFace,
422 TopoDS_Shape& aNewEdge,
424 const Sweep_NumShape&,
425 const Sweep_NumShape& aDirV,
426 const TopAbs_Orientation orien)
429 GeomAdaptor_Surface AS(BRep_Tool::Surface(TopoDS::Face(aNewFace),Loc));
430 Standard_Real First,Last;
436 if (AS.GetType()==GeomAbs_Plane){
437 gp_Pln pln = AS.Plane();
438 gp_Ax3 ax3 = pln.Position();
439 Handle(Geom_Line) GL = Handle(Geom_Line)::DownCast
440 (BRep_Tool::Curve(TopoDS::Edge(aNewEdge),Loc,First,Last));
441 gp_Lin gl = GL->Lin();
442 gl.Transform(Loc.Transformation());
443 point = gl.Location();
444 gp_Dir dir = gl.Direction();
445 ElSLib::PlaneParameters(ax3,point,u,v);
447 dir2d.SetCoord(dir.Dot(ax3.XDirection()),dir.Dot(ax3.YDirection()));
448 L.SetLocation(pnt2d);
449 L.SetDirection(dir2d);
451 else if (AS.GetType()==GeomAbs_Torus){
452 gp_Torus tor = AS.Torus();
453 BRepAdaptor_Curve BC(TopoDS::Edge(aNewEdge));
454 Standard_Real U = BC.FirstParameter();
456 if (point.Distance(tor.Location()) < Precision::Confusion()) {
458 // modified by NIZHNY-EAP Wed Mar 1 17:49:29 2000 ___BEGIN___
462 ElSLib::TorusParameters(tor.Position(),tor.MajorRadius(),
463 tor.MinorRadius(),point,u,v);
466 v = ElCLib::InPeriod(v,0.,2*PI);
467 if((2*PI - v) <= Precision::PConfusion()) v -= 2*PI;
468 if (aDirV.Index() == 2) {
469 Standard_Real uLeft = u-myAng;
470 ElCLib::AdjustPeriodic(-PI,PI,Precision::PConfusion(),uLeft,u);
473 Standard_Real uRight = u+myAng;
474 ElCLib::AdjustPeriodic(-PI,PI,Precision::PConfusion(),u,uRight);
476 // modified by NIZHNY-EAP Wed Mar 1 17:49:32 2000 ___END___
477 pnt2d.SetCoord(u,v-U);
478 L.SetLocation(pnt2d);
479 L.SetDirection(gp::DY2d());
481 else if (AS.GetType()==GeomAbs_Sphere){
482 gp_Sphere sph = AS.Sphere();
483 BRepAdaptor_Curve BC(TopoDS::Edge(aNewEdge));
484 Standard_Real U = BC.FirstParameter();
486 ElSLib::SphereParameters(sph.Position(),sph.Radius(),point,u,v);
488 if (aDirV.Index() == 2) u = myAng;
489 pnt2d.SetCoord(u,v-U);
490 L.SetLocation(pnt2d);
491 L.SetDirection(gp::DY2d());
495 if (aDirV.Index() == 2) u = myAng;
496 L.SetLocation(gp_Pnt2d(u,0));
497 L.SetDirection(gp::DY2d());
499 Handle(Geom2d_Line) GL = new Geom2d_Line(L);
500 SetThePCurve(myBuilder.Builder(),
501 TopoDS::Edge(aNewEdge),
502 TopoDS::Face(aNewFace),
508 //=======================================================================
509 //function : SetDirectingPCurve
511 //=======================================================================
513 void BRepSweep_Rotation::SetDirectingPCurve
514 (const TopoDS_Shape& aNewFace,
515 TopoDS_Shape& aNewEdge,
516 const TopoDS_Shape& aGenE,
517 const TopoDS_Shape& aGenV,
518 const Sweep_NumShape&,
519 const TopAbs_Orientation orien)
522 GeomAdaptor_Surface AS(BRep_Tool::Surface(TopoDS::Face(aNewFace),Loc));
524 par = BRep_Tool::Parameter(TopoDS::Vertex(aGenV),TopoDS::Edge(aGenE));
525 gp_Pnt p2 = BRep_Tool::Pnt(TopoDS::Vertex(aGenV));
528 Handle(Geom2d_Curve) thePCurve;
530 switch(AS.GetType()){
534 gp_Pln pln = AS.Plane();
535 gp_Ax3 ax3 = pln.Position();
536 gp_Pnt p1 = pln.Location();
537 Standard_Real R = p1.Distance(p2);
538 ElSLib::PlaneParameters(ax3,p2,u,v);
540 gp_Ax22d axe(gp::Origin2d(),dx2d,gp::DY2d());
542 Handle(Geom2d_Circle) GC = new Geom2d_Circle(C);
549 gp_Cone cone = AS.Cone();
550 ElSLib::ConeParameters(cone.Position(),cone.RefRadius(),
551 cone.SemiAngle(),p2,u,v);
553 gp_Lin2d L(p22d,gp::DX2d());
554 Handle(Geom2d_Line) GL = new Geom2d_Line(L);
559 case GeomAbs_Sphere :
561 gp_Sphere sph = AS.Sphere();
562 ElSLib::SphereParameters(sph.Position(),sph.Radius(),p2,u,v);
564 gp_Lin2d L(p22d,gp::DX2d());
565 Handle(Geom2d_Line) GL = new Geom2d_Line(L);
573 Standard_Real u1,u2,v1,v2;
574 gp_Torus tor = AS.Torus();
575 BRepAdaptor_Curve BC(TopoDS::Edge(aGenE));
576 p1 = BC.Value(BC.FirstParameter());
577 if (p1.Distance(tor.Location()) < Precision::Confusion()){
579 // modified by NIZHNY-EAP Thu Mar 2 09:43:26 2000 ___BEGIN___
581 // modified by NIZHNY-EAP Thu Mar 2 15:28:59 2000 ___END___
584 ElSLib::TorusParameters(tor.Position(),tor.MajorRadius(),
585 tor.MinorRadius(),p1,u1,v1);
587 p2 = BC.Value(BC.LastParameter());
588 if (p2.Distance(tor.Location()) < Precision::Confusion()){
592 ElSLib::TorusParameters(tor.Position(),tor.MajorRadius(),
593 tor.MinorRadius(),p2,u2,v2);
595 ElCLib::AdjustPeriodic(0.,2*PI,Precision::PConfusion(),v1,v2);
596 // modified by NIZHNY-EAP Thu Mar 2 15:29:04 2000 ___BEGIN___
598 ElCLib::AdjustPeriodic(-PI,PI,Precision::PConfusion(),u1,u2);
599 if (aGenV.Orientation()==TopAbs_FORWARD){
600 p22d.SetCoord(u1,v1);
603 p22d.SetCoord(u1,v2);
604 // modified by NIZHNY-EAP Thu Mar 2 09:43:32 2000 ___END___
606 gp_Lin2d L(p22d,gp::DX2d());
607 Handle(Geom2d_Line) GL = new Geom2d_Line(L);
614 p22d.SetCoord(0.,par);
615 gp_Lin2d L(p22d,gp::DX2d());
616 Handle(Geom2d_Line) GL = new Geom2d_Line(L);
621 SetThePCurve(myBuilder.Builder(),
622 TopoDS::Edge(aNewEdge),
623 TopoDS::Face(aNewFace),
628 //modified by NIZNHY-PKV Tue Jun 14 08:33:55 2011f
629 //=======================================================================
630 //function : DirectSolid
632 //=======================================================================
634 BRepSweep_Rotation::DirectSolid (const TopoDS_Shape& aGenS,
635 const Sweep_NumShape&)
636 { // compare the face normal and the direction
637 Standard_Real aU1, aU2, aV1, aV2, aUx, aVx, aX, aMV2, aTol2, aTx;
638 TopAbs_Orientation aOr;
641 BRepAdaptor_Surface surf(TopoDS::Face(aGenS));
643 aTol2=Precision::Confusion();
646 const gp_Pnt& aPAxeLoc=myAxe.Location();
647 const gp_Dir& aPAxeDir=myAxe.Direction();
649 aU1=surf.FirstUParameter();
650 aU2=surf.LastUParameter();
651 aV1=surf.FirstVParameter();
652 aV2=surf.LastVParameter();
657 surf.D1(aUx, aVx, aP, du, dv);
659 gp_Vec aV(aPAxeLoc, aP);
661 aMV2=aV.SquareMagnitude();
664 aUx=aU1*(1.-aTx)+aU2*aTx;
665 aVx=aV1*(1.-aTx)+aV2*aTx;
666 surf.D1(aUx, aVx, aP, du, dv);
667 aV.SetXYZ(aP.XYZ()-aPAxeLoc.XYZ());
671 aX = aV.DotCross(du, dv);
672 aOr = (aX > 0.) ? TopAbs_FORWARD : TopAbs_REVERSED;
676 //=======================================================================
677 //function : DirectSolid
679 //=======================================================================
681 BRepSweep_Rotation::DirectSolid (const TopoDS_Shape& aGenS,
682 const Sweep_NumShape&)
684 // compare the face normal and the direction
685 BRepAdaptor_Surface surf(TopoDS::Face(aGenS));
688 surf.D1((surf.FirstUParameter() + surf.LastUParameter()) / 2.,
689 (surf.FirstVParameter() + surf.LastVParameter()) / 2.,
692 gp_Vec V(myAxe.Location(),P);
693 V.Cross(myAxe.Direction());
694 Standard_Real x = V.DotCross(du,dv);
695 TopAbs_Orientation orient = (x > 0) ? TopAbs_FORWARD : TopAbs_REVERSED;
699 //modified by NIZNHY-PKV Tue Jun 14 08:33:59 2011t
701 //=======================================================================
702 //function : GGDShapeIsToAdd
704 //=======================================================================
706 Standard_Boolean BRepSweep_Rotation::GGDShapeIsToAdd
707 (const TopoDS_Shape& aNewShape,
708 const TopoDS_Shape& aNewSubShape,
709 const TopoDS_Shape& aGenS,
710 const TopoDS_Shape& aSubGenS,
711 const Sweep_NumShape& aDirS )const
713 if (aNewShape.ShapeType()==TopAbs_FACE &&
714 aNewSubShape.ShapeType()==TopAbs_EDGE &&
715 aGenS.ShapeType()==TopAbs_EDGE &&
716 aSubGenS.ShapeType()==TopAbs_VERTEX &&
717 aDirS.Type()==TopAbs_EDGE){
719 GeomAdaptor_Surface AS(BRep_Tool::Surface(TopoDS::Face(aNewShape),Loc));
720 if (AS.GetType()==GeomAbs_Plane){
721 return (!IsInvariant(aSubGenS));
724 return Standard_True;
728 return Standard_True;
733 //=======================================================================
734 //function : GDDShapeIsToAdd
736 //=======================================================================
738 Standard_Boolean BRepSweep_Rotation::GDDShapeIsToAdd
739 (const TopoDS_Shape& aNewShape,
740 const TopoDS_Shape& aNewSubShape,
741 const TopoDS_Shape& aGenS,
742 const Sweep_NumShape& aDirS,
743 const Sweep_NumShape& aSubDirS )const
745 if ( aNewShape.ShapeType() == TopAbs_SOLID &&
746 aNewSubShape.ShapeType() == TopAbs_FACE &&
747 aGenS.ShapeType() == TopAbs_FACE &&
748 aDirS.Type() == TopAbs_EDGE &&
749 aSubDirS.Type() == TopAbs_VERTEX ){
750 return ( Abs(myAng - 2 * PI) > Precision::Angular() );
752 else if ( aNewShape.ShapeType() == TopAbs_FACE &&
753 aNewSubShape.ShapeType() == TopAbs_EDGE &&
754 aGenS.ShapeType() == TopAbs_EDGE &&
755 aDirS.Type() == TopAbs_EDGE &&
756 aSubDirS.Type() == TopAbs_VERTEX ){
758 GeomAdaptor_Surface AS(BRep_Tool::Surface(TopoDS::Face(aNewShape),Loc));
759 if (AS.GetType()==GeomAbs_Plane){
760 return ( Abs(myAng - 2 * PI) > Precision::Angular() );
763 return Standard_True;
767 return Standard_True;
772 //=======================================================================
773 //function : SeparatedWires
775 //=======================================================================
777 Standard_Boolean BRepSweep_Rotation::SeparatedWires
778 (const TopoDS_Shape& aNewShape,
779 const TopoDS_Shape& aNewSubShape,
780 const TopoDS_Shape& aGenS,
781 const TopoDS_Shape& aSubGenS,
782 const Sweep_NumShape& aDirS )const
784 if (aNewShape.ShapeType()==TopAbs_FACE &&
785 aNewSubShape.ShapeType()==TopAbs_EDGE &&
786 aGenS.ShapeType()==TopAbs_EDGE &&
787 aSubGenS.ShapeType()==TopAbs_VERTEX &&
788 aDirS.Type()==TopAbs_EDGE){
790 GeomAdaptor_Surface AS(BRep_Tool::Surface(TopoDS::Face(aNewShape),Loc));
791 if (AS.GetType()==GeomAbs_Plane){
792 return (Abs(myAng-2*PI) <= Precision::Angular());
795 return Standard_False;
799 return Standard_False;
803 //=======================================================================
804 //function : SplitShell
806 //=======================================================================
808 TopoDS_Shape BRepSweep_Rotation::SplitShell(const TopoDS_Shape& aNewShape)const
815 //=======================================================================
816 //function : HasShape
818 //=======================================================================
820 Standard_Boolean BRepSweep_Rotation::HasShape
821 (const TopoDS_Shape& aGenS,
822 const Sweep_NumShape& aDirS)const
824 if(aDirS.Type()==TopAbs_EDGE&&
825 aGenS.ShapeType()==TopAbs_EDGE){
826 return !IsInvariant(aGenS);
829 return Standard_True;
834 //=======================================================================
835 //function : IsInvariant
837 //=======================================================================
839 Standard_Boolean BRepSweep_Rotation::IsInvariant
840 (const TopoDS_Shape& aGenS)const
842 if(aGenS.ShapeType()==TopAbs_EDGE){
844 Standard_Real First,Last;
846 C = BRep_Tool::Curve(TopoDS::Edge(aGenS),Loc,First,Last);
847 Handle(Standard_Type) TheType = C->DynamicType();
848 if ( TheType == STANDARD_TYPE(Geom_Line)) {
849 TopoDS_Vertex V1, V2;
850 TopExp::Vertices(TopoDS::Edge(aGenS), V1, V2);
851 return ( IsInvariant(V1) && IsInvariant(V2));
854 return Standard_False;
857 else if(aGenS.ShapeType()==TopAbs_VERTEX){
858 gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aGenS));
859 gp_Lin Lin (myAxe.Location(), myAxe.Direction());
860 return ( Lin.Distance(P) <= BRep_Tool::Tolerance(TopoDS::Vertex(aGenS)));
863 return Standard_False;
866 //=======================================================================
869 //=======================================================================
871 Standard_Real BRepSweep_Rotation::Angle()const
876 //=======================================================================
879 //=======================================================================
881 gp_Ax1 BRepSweep_Rotation::Axe()const