1 // Created on: 1993-02-15
2 // Created by: Laurent BOURESCHE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepSweep_Rotation.ixx>
18 #include <BRepTools_Quilt.hxx>
19 #include <BRepAdaptor_Curve.hxx>
20 #include <BRepAdaptor_Surface.hxx>
21 #include <BRep_Tool.hxx>
22 #include <BRepTools.hxx>
24 #include <TopoDS_Shape.hxx>
25 #include <TopoDS_Vertex.hxx>
29 #include <GeomAdaptor_Curve.hxx>
30 #include <GeomAdaptor_Surface.hxx>
31 #include <Adaptor3d_SurfaceOfRevolution.hxx>
32 #include <Geom_SurfaceOfRevolution.hxx>
33 #include <Geom_CylindricalSurface.hxx>
34 #include <Geom_ConicalSurface.hxx>
35 #include <Geom_SphericalSurface.hxx>
36 #include <Geom_ToroidalSurface.hxx>
37 #include <Geom_Plane.hxx>
38 #include <Geom_Circle.hxx>
39 #include <Geom_Line.hxx>
40 #include <Geom2d_Circle.hxx>
41 #include <Geom2d_Line.hxx>
43 #include <gp_Trsf.hxx>
44 #include <gp_Circ2d.hxx>
46 #include <gp_Dir2d.hxx>
48 #include <gp_Lin2d.hxx>
50 #include <gp_Pnt2d.hxx>
51 #include <gp_Ax22d.hxx>
52 #include <gp_Cylinder.hxx>
54 #include <gp_Cone.hxx>
55 #include <gp_Sphere.hxx>
56 #include <gp_Torus.hxx>
58 #include <Precision.hxx>
59 #include <Standard_ConstructionError.hxx>
61 #include <GeomAdaptor_HCurve.hxx>
62 #include <Geom_TrimmedCurve.hxx>
63 #include <Geom_Curve.hxx>
64 #include <Geom_Surface.hxx>
66 static Standard_Real ComputeTolerance(TopoDS_Edge& E,
68 const Handle(Geom2d_Curve)& C)
71 if(BRep_Tool::Degenerated(E)) return BRep_Tool::Tolerance(E);
73 Standard_Real first,last;
75 Handle(Geom_Surface) surf = BRep_Tool::Surface(F);
76 Handle(Geom_Curve) c3d = BRep_Tool::Curve(E,first,last);
78 Standard_Real d2 = 0.;
79 Standard_Integer nn = 23;
80 Standard_Real unsurnn = 1./nn;
81 for(Standard_Integer i = 0; i <= nn; i++){
82 Standard_Real t = unsurnn*i;
83 Standard_Real u = first*(1.-t) + last*t;
84 gp_Pnt Pc3d = c3d->Value(u);
85 gp_Pnt2d UV = C->Value(u);
86 gp_Pnt Pcons = surf->Value(UV.X(),UV.Y());
87 if (Precision::IsInfinite(Pcons.X()) ||
88 Precision::IsInfinite(Pcons.Y()) ||
89 Precision::IsInfinite(Pcons.Z())) {
90 d2=Precision::Infinite();
93 Standard_Real temp = Pc3d.SquareDistance(Pcons);
94 if(temp > d2) d2 = temp;
97 if(d2<1.e-7) d2 = 1.e-7;
101 static void SetThePCurve(const BRep_Builder& B,
103 const TopoDS_Face& F,
104 const TopAbs_Orientation O,
105 const Handle(Geom2d_Curve)& C)
107 // check if there is already a pcurve
109 Handle(Geom2d_Curve) OC;
111 Handle(Geom_Plane) GP = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(F,SL));
113 OC = BRep_Tool::CurveOnSurface(E,F,f,l);
115 B.UpdateEdge(E,C,F,ComputeTolerance(E,F,C));
117 if (O == TopAbs_REVERSED)
118 B.UpdateEdge(E,OC,C,F,ComputeTolerance(E,F,C));
120 B.UpdateEdge(E,C,OC,F,ComputeTolerance(E,F,C));
124 //=======================================================================
125 //function : BRepSweep_Rotation
127 //=======================================================================
129 BRepSweep_Rotation::BRepSweep_Rotation(const TopoDS_Shape& S,
130 const Sweep_NumShape& N,
131 const TopLoc_Location& L,
133 const Standard_Real D,
134 const Standard_Boolean C):
135 BRepSweep_Trsf(BRep_Builder(),S,N,L,C),
140 Standard_ConstructionError_Raise_if(D < Precision::Angular(),
141 "BRepSweep_Rotation::Constructor");
146 //=======================================================================
147 //function : MakeEmptyVertex
149 //=======================================================================
151 TopoDS_Shape BRepSweep_Rotation::MakeEmptyVertex
152 (const TopoDS_Shape& aGenV,
153 const Sweep_NumShape& aDirV)
155 //call only in construction mode with copy.
156 Standard_ConstructionError_Raise_if
157 (!myCopy,"BRepSweep_Translation::MakeEmptyVertex");
158 gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aGenV));
160 if (aDirV.Index()==2) P.Transform(myLocation.Transformation());
161 ////// modified by jgv, 1.10.01, for buc61005 //////
162 //myBuilder.Builder().MakeVertex(V,P,Precision::Confusion());
163 myBuilder.Builder().MakeVertex( V, P, BRep_Tool::Tolerance(TopoDS::Vertex(aGenV)) );
164 ////////////////////////////////////////////////////
165 if (aDirV.Index() == 1 &&
166 IsInvariant(aGenV) &&
167 myDirShapeTool.NbShapes() == 3) {
168 myBuiltShapes(myGenShapeTool.Index(aGenV),3) = Standard_True;
169 myShapes(myGenShapeTool.Index(aGenV),3) = V;
175 //=======================================================================
176 //function : MakeEmptyDirectingEdge
178 //=======================================================================
180 TopoDS_Shape BRepSweep_Rotation::MakeEmptyDirectingEdge
181 (const TopoDS_Shape& aGenV,
182 const Sweep_NumShape&)
185 gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aGenV));
186 gp_Dir Dirz(myAxe.Direction());
188 gp_Pnt O(myAxe.Location());
189 O.Translate(V.Dot(gp_Vec(O,P)) * V);
190 if (O.IsEqual(P,Precision::Confusion())) {
191 // make a degenerated edge
192 // temporary make 3D curve null so that
193 // parameters should be registered.
194 // myBuilder.Builder().MakeEdge(E);
196 Handle(Geom_Circle) GC = new Geom_Circle(Axis,0.);
198 MakeEdge(E,GC,BRep_Tool::Tolerance(TopoDS::Vertex(aGenV)));
199 myBuilder.Builder().Degenerated(E,Standard_True);
202 gp_Ax2 Axis(O,Dirz,gp_Dir(gp_Vec(O,P)));
203 Handle(Geom_Circle) GC = new Geom_Circle(Axis,O.Distance(P));
204 Standard_Real tol = BRep_Tool::Tolerance(TopoDS::Vertex(aGenV));
205 myBuilder.Builder().MakeEdge(E, GC, tol);
211 //=======================================================================
212 //function : MakeEmptyGeneratingEdge
214 //=======================================================================
216 TopoDS_Shape BRepSweep_Rotation::MakeEmptyGeneratingEdge
217 (const TopoDS_Shape& aGenE,
218 const Sweep_NumShape& aDirV)
220 //call in case of construction with copy, or only when meridian touches myaxe.
221 Standard_Real First,Last;
223 Handle(Geom_Curve) C = Handle(Geom_Curve)::DownCast
224 (BRep_Tool::Curve(TopoDS::Edge(aGenE),Loc,First,Last)->Copy());
225 C->Transform(Loc.Transformation());
227 if(aDirV.Index() == 2) C->Transform(myLocation.Transformation());
228 myBuilder.Builder().MakeEdge(E,C,BRep_Tool::Tolerance(TopoDS::Edge(aGenE)));
229 if (aDirV.Index() == 1 &&
230 IsInvariant(aGenE) &&
231 myDirShapeTool.NbShapes() == 3) {
232 myBuiltShapes(myGenShapeTool.Index(aGenE),3) = Standard_True;
233 myShapes(myGenShapeTool.Index(aGenE),3) = E;
239 //=======================================================================
240 //function : SetParameters
242 //=======================================================================
244 void BRepSweep_Rotation::SetParameters
245 (const TopoDS_Shape& aNewFace,
246 TopoDS_Shape& aNewVertex,
247 const TopoDS_Shape& aGenF,
248 const TopoDS_Shape& aGenV,
249 const Sweep_NumShape&)
251 //Glue the parameter of vertices directly included in cap faces.
252 gp_Pnt2d pnt2d = BRep_Tool::Parameters(TopoDS::Vertex(aGenV),
253 TopoDS::Face(aGenF));
254 myBuilder.Builder().UpdateVertex
255 (TopoDS::Vertex(aNewVertex),pnt2d.X(),pnt2d.Y(),
256 TopoDS::Face(aNewFace),Precision::PConfusion());
259 //=======================================================================
260 //function : SetDirectingParameter
262 //=======================================================================
264 void BRepSweep_Rotation::SetDirectingParameter
265 (const TopoDS_Shape& aNewEdge,
266 TopoDS_Shape& aNewVertex,
268 const Sweep_NumShape&,
269 const Sweep_NumShape& aDirV)
271 Standard_Real param = 0;
272 TopAbs_Orientation ori = TopAbs_FORWARD;
273 if (aDirV.Index() == 2) {
275 ori = TopAbs_REVERSED;
277 TopoDS_Vertex V_wnt = TopoDS::Vertex(aNewVertex);
278 V_wnt.Orientation(ori);
279 myBuilder.Builder().UpdateVertex(V_wnt,
280 param,TopoDS::Edge(aNewEdge),
281 Precision::PConfusion());
285 //=======================================================================
286 //function : SetGeneratingParameter
288 //=======================================================================
290 void BRepSweep_Rotation::SetGeneratingParameter
291 (const TopoDS_Shape& aNewEdge,
292 TopoDS_Shape& aNewVertex,
293 const TopoDS_Shape& aGenE,
294 const TopoDS_Shape& aGenV,
295 const Sweep_NumShape&)
297 TopoDS_Vertex vbid = TopoDS::Vertex(aNewVertex);
298 vbid.Orientation(aGenV.Orientation());
299 myBuilder.Builder().UpdateVertex
301 BRep_Tool::Parameter(TopoDS::Vertex(aGenV),TopoDS::Edge(aGenE)),
302 TopoDS::Edge(aNewEdge),Precision::PConfusion());
306 //=======================================================================
307 //function : MakeEmptyFace
309 //=======================================================================
311 TopoDS_Shape BRepSweep_Rotation::MakeEmptyFace
312 (const TopoDS_Shape& aGenS,
313 const Sweep_NumShape& aDirS)
317 Handle(Geom_Surface) S;
318 if(aGenS.ShapeType()==TopAbs_EDGE){
320 Standard_Real First,Last;
321 Handle(Geom_Curve) C = BRep_Tool::Curve(TopoDS::Edge(aGenS),L,First,Last);
322 toler = BRep_Tool::Tolerance(TopoDS::Edge(aGenS));
323 gp_Trsf Tr = L.Transformation();
324 C = Handle(Geom_Curve)::DownCast(C->Copy());
325 //// modified by jgv, 9.12.03 ////
326 C = new Geom_TrimmedCurve( C, First, Last );
327 //////////////////////////////////
330 Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve();
331 HC->ChangeCurve().Load(C,First,Last);
332 Adaptor3d_SurfaceOfRevolution AS(HC,myAxe);
333 switch(AS.GetType()){
336 Handle(Geom_Plane) Pl = new Geom_Plane(AS.Plane());
340 case GeomAbs_Cylinder :
342 Handle(Geom_CylindricalSurface) Cy =
343 new Geom_CylindricalSurface(AS.Cylinder());
347 case GeomAbs_Sphere :
349 Handle(Geom_SphericalSurface) Sp =
350 new Geom_SphericalSurface(AS.Sphere());
356 Handle(Geom_ConicalSurface) Co =
357 new Geom_ConicalSurface(AS.Cone());
363 Handle(Geom_ToroidalSurface) To =
364 new Geom_ToroidalSurface(AS.Torus());
370 Handle(Geom_SurfaceOfRevolution) Se =
371 new Geom_SurfaceOfRevolution(C,myAxe);
379 S = BRep_Tool::Surface(TopoDS::Face(aGenS),L);
380 toler = BRep_Tool::Tolerance(TopoDS::Face(aGenS));
381 gp_Trsf Tr = L.Transformation();
382 S = Handle(Geom_Surface)::DownCast(S->Copy());
384 if (aDirS.Index()==2) S->Transform(myLocation.Transformation());
386 myBuilder.Builder().MakeFace(F,S,toler);
391 //=======================================================================
392 //function : SetPCurve
394 //=======================================================================
396 void BRepSweep_Rotation::SetPCurve
397 (const TopoDS_Shape& aNewFace,
398 TopoDS_Shape& aNewEdge,
399 const TopoDS_Shape& aGenF,
400 const TopoDS_Shape& aGenE,
401 const Sweep_NumShape&,
402 const TopAbs_Orientation orien)
404 //Set on edges of cap faces the same pcurves as
405 //on edges of the generator face.
406 Standard_Real First,Last;
407 SetThePCurve(myBuilder.Builder(),
408 TopoDS::Edge(aNewEdge),
409 TopoDS::Face(aNewFace),
411 BRep_Tool::CurveOnSurface
412 (TopoDS::Edge(aGenE),TopoDS::Face(aGenF),First,Last));
416 //=======================================================================
417 //function : SetGeneratingPCurve
419 //=======================================================================
421 void BRepSweep_Rotation::SetGeneratingPCurve
422 (const TopoDS_Shape& aNewFace,
423 TopoDS_Shape& aNewEdge,
425 const Sweep_NumShape&,
426 const Sweep_NumShape& aDirV,
427 const TopAbs_Orientation orien)
430 GeomAdaptor_Surface AS(BRep_Tool::Surface(TopoDS::Face(aNewFace),Loc));
431 Standard_Real First,Last;
437 if (AS.GetType()==GeomAbs_Plane){
438 gp_Pln pln = AS.Plane();
439 gp_Ax3 ax3 = pln.Position();
440 Handle(Geom_Curve) aC = BRep_Tool::Curve(TopoDS::Edge(aNewEdge),Loc,First,Last);
441 Handle(Geom_Line) GL = Handle(Geom_Line)::DownCast(aC);
443 Handle(Geom_TrimmedCurve) aTrimmedCurve = Handle(Geom_TrimmedCurve)::DownCast(aC);
444 if (!aTrimmedCurve.IsNull()) {
445 GL = Handle(Geom_Line)::DownCast(aTrimmedCurve->BasisCurve());
447 Standard_ConstructionError::Raise("BRepSweep_Rotation::SetGeneratingPCurve");
451 gp_Lin gl = GL->Lin();
452 gl.Transform(Loc.Transformation());
453 point = gl.Location();
454 gp_Dir dir = gl.Direction();
455 ElSLib::PlaneParameters(ax3,point,u,v);
457 dir2d.SetCoord(dir.Dot(ax3.XDirection()),dir.Dot(ax3.YDirection()));
458 L.SetLocation(pnt2d);
459 L.SetDirection(dir2d);
461 else if (AS.GetType()==GeomAbs_Torus){
462 gp_Torus tor = AS.Torus();
463 BRepAdaptor_Curve BC(TopoDS::Edge(aNewEdge));
464 Standard_Real U = BC.FirstParameter();
466 if (point.Distance(tor.Location()) < Precision::Confusion()) {
468 // modified by NIZHNY-EAP Wed Mar 1 17:49:29 2000 ___BEGIN___
472 ElSLib::TorusParameters(tor.Position(),tor.MajorRadius(),
473 tor.MinorRadius(),point,u,v);
476 v = ElCLib::InPeriod(v,0.,2*M_PI);
477 if((2*M_PI - v) <= Precision::PConfusion()) v -= 2*M_PI;
478 if (aDirV.Index() == 2) {
479 Standard_Real uLeft = u-myAng;
480 ElCLib::AdjustPeriodic(-M_PI,M_PI,Precision::PConfusion(),uLeft,u);
483 Standard_Real uRight = u+myAng;
484 ElCLib::AdjustPeriodic(-M_PI,M_PI,Precision::PConfusion(),u,uRight);
486 // modified by NIZHNY-EAP Wed Mar 1 17:49:32 2000 ___END___
487 pnt2d.SetCoord(u,v-U);
488 L.SetLocation(pnt2d);
489 L.SetDirection(gp::DY2d());
491 else if (AS.GetType()==GeomAbs_Sphere){
492 gp_Sphere sph = AS.Sphere();
493 BRepAdaptor_Curve BC(TopoDS::Edge(aNewEdge));
494 Standard_Real U = BC.FirstParameter();
496 ElSLib::SphereParameters(sph.Position(),sph.Radius(),point,u,v);
498 if (aDirV.Index() == 2) u = myAng;
499 pnt2d.SetCoord(u,v-U);
500 L.SetLocation(pnt2d);
501 L.SetDirection(gp::DY2d());
505 if (aDirV.Index() == 2) u = myAng;
506 L.SetLocation(gp_Pnt2d(u,0));
507 L.SetDirection(gp::DY2d());
509 Handle(Geom2d_Line) GL = new Geom2d_Line(L);
510 SetThePCurve(myBuilder.Builder(),
511 TopoDS::Edge(aNewEdge),
512 TopoDS::Face(aNewFace),
518 //=======================================================================
519 //function : SetDirectingPCurve
521 //=======================================================================
523 void BRepSweep_Rotation::SetDirectingPCurve
524 (const TopoDS_Shape& aNewFace,
525 TopoDS_Shape& aNewEdge,
526 const TopoDS_Shape& aGenE,
527 const TopoDS_Shape& aGenV,
528 const Sweep_NumShape&,
529 const TopAbs_Orientation orien)
532 GeomAdaptor_Surface AS(BRep_Tool::Surface(TopoDS::Face(aNewFace),Loc));
534 par = BRep_Tool::Parameter(TopoDS::Vertex(aGenV),TopoDS::Edge(aGenE));
535 gp_Pnt p2 = BRep_Tool::Pnt(TopoDS::Vertex(aGenV));
538 Handle(Geom2d_Curve) thePCurve;
540 switch(AS.GetType()){
544 gp_Pln pln = AS.Plane();
545 gp_Ax3 ax3 = pln.Position();
546 gp_Pnt p1 = pln.Location();
547 Standard_Real R = p1.Distance(p2);
548 ElSLib::PlaneParameters(ax3,p2,u,v);
550 gp_Ax22d axe(gp::Origin2d(),dx2d,gp::DY2d());
552 Handle(Geom2d_Circle) GC = new Geom2d_Circle(C);
559 gp_Cone cone = AS.Cone();
560 ElSLib::ConeParameters(cone.Position(),cone.RefRadius(),
561 cone.SemiAngle(),p2,u,v);
563 gp_Lin2d L(p22d,gp::DX2d());
564 Handle(Geom2d_Line) GL = new Geom2d_Line(L);
569 case GeomAbs_Sphere :
571 gp_Sphere sph = AS.Sphere();
572 ElSLib::SphereParameters(sph.Position(),sph.Radius(),p2,u,v);
574 gp_Lin2d L(p22d,gp::DX2d());
575 Handle(Geom2d_Line) GL = new Geom2d_Line(L);
583 Standard_Real u1,u2,v1,v2;
584 gp_Torus tor = AS.Torus();
585 BRepAdaptor_Curve BC(TopoDS::Edge(aGenE));
586 p1 = BC.Value(BC.FirstParameter());
587 if (p1.Distance(tor.Location()) < Precision::Confusion()){
589 // modified by NIZHNY-EAP Thu Mar 2 09:43:26 2000 ___BEGIN___
591 // modified by NIZHNY-EAP Thu Mar 2 15:28:59 2000 ___END___
594 ElSLib::TorusParameters(tor.Position(),tor.MajorRadius(),
595 tor.MinorRadius(),p1,u1,v1);
597 p2 = BC.Value(BC.LastParameter());
598 if (p2.Distance(tor.Location()) < Precision::Confusion()){
602 ElSLib::TorusParameters(tor.Position(),tor.MajorRadius(),
603 tor.MinorRadius(),p2,u2,v2);
605 ElCLib::AdjustPeriodic(0.,2*M_PI,Precision::PConfusion(),v1,v2);
606 // modified by NIZHNY-EAP Thu Mar 2 15:29:04 2000 ___BEGIN___
608 ElCLib::AdjustPeriodic(-M_PI,M_PI,Precision::PConfusion(),u1,u2);
609 if (aGenV.Orientation()==TopAbs_FORWARD){
610 p22d.SetCoord(u1,v1);
613 p22d.SetCoord(u1,v2);
614 // modified by NIZHNY-EAP Thu Mar 2 09:43:32 2000 ___END___
616 gp_Lin2d L(p22d,gp::DX2d());
617 Handle(Geom2d_Line) GL = new Geom2d_Line(L);
624 p22d.SetCoord(0.,par);
625 gp_Lin2d L(p22d,gp::DX2d());
626 Handle(Geom2d_Line) GL = new Geom2d_Line(L);
631 SetThePCurve(myBuilder.Builder(),
632 TopoDS::Edge(aNewEdge),
633 TopoDS::Face(aNewFace),
638 //modified by NIZNHY-PKV Tue Jun 14 08:33:55 2011f
639 //=======================================================================
640 //function : DirectSolid
642 //=======================================================================
644 BRepSweep_Rotation::DirectSolid (const TopoDS_Shape& aGenS,
645 const Sweep_NumShape&)
646 { // compare the face normal and the direction
647 Standard_Real aU1, aU2, aV1, aV2, aUx, aVx, aX, aMV2, aTol2, aTx;
648 TopAbs_Orientation aOr;
651 BRepAdaptor_Surface surf(TopoDS::Face(aGenS));
653 aTol2=Precision::Confusion();
656 const gp_Pnt& aPAxeLoc=myAxe.Location();
657 const gp_Dir& aPAxeDir=myAxe.Direction();
659 aU1=surf.FirstUParameter();
660 aU2=surf.LastUParameter();
661 aV1=surf.FirstVParameter();
662 aV2=surf.LastVParameter();
667 surf.D1(aUx, aVx, aP, du, dv);
669 gp_Vec aV(aPAxeLoc, aP);
671 aMV2=aV.SquareMagnitude();
674 aUx=aU1*(1.-aTx)+aU2*aTx;
675 aVx=aV1*(1.-aTx)+aV2*aTx;
676 surf.D1(aUx, aVx, aP, du, dv);
677 aV.SetXYZ(aP.XYZ()-aPAxeLoc.XYZ());
681 aX = aV.DotCross(du, dv);
682 aOr = (aX > 0.) ? TopAbs_FORWARD : TopAbs_REVERSED;
686 //=======================================================================
687 //function : DirectSolid
689 //=======================================================================
691 BRepSweep_Rotation::DirectSolid (const TopoDS_Shape& aGenS,
692 const Sweep_NumShape&)
694 // compare the face normal and the direction
695 BRepAdaptor_Surface surf(TopoDS::Face(aGenS));
698 surf.D1((surf.FirstUParameter() + surf.LastUParameter()) / 2.,
699 (surf.FirstVParameter() + surf.LastVParameter()) / 2.,
702 gp_Vec V(myAxe.Location(),P);
703 V.Cross(myAxe.Direction());
704 Standard_Real x = V.DotCross(du,dv);
705 TopAbs_Orientation orient = (x > 0) ? TopAbs_FORWARD : TopAbs_REVERSED;
709 //modified by NIZNHY-PKV Tue Jun 14 08:33:59 2011t
711 //=======================================================================
712 //function : GGDShapeIsToAdd
714 //=======================================================================
716 Standard_Boolean BRepSweep_Rotation::GGDShapeIsToAdd
717 (const TopoDS_Shape& aNewShape,
718 const TopoDS_Shape& aNewSubShape,
719 const TopoDS_Shape& aGenS,
720 const TopoDS_Shape& aSubGenS,
721 const Sweep_NumShape& aDirS )const
723 if (aNewShape.ShapeType()==TopAbs_FACE &&
724 aNewSubShape.ShapeType()==TopAbs_EDGE &&
725 aGenS.ShapeType()==TopAbs_EDGE &&
726 aSubGenS.ShapeType()==TopAbs_VERTEX &&
727 aDirS.Type()==TopAbs_EDGE){
729 GeomAdaptor_Surface AS(BRep_Tool::Surface(TopoDS::Face(aNewShape),Loc));
730 if (AS.GetType()==GeomAbs_Plane){
731 return (!IsInvariant(aSubGenS));
734 return Standard_True;
738 return Standard_True;
743 //=======================================================================
744 //function : GDDShapeIsToAdd
746 //=======================================================================
748 Standard_Boolean BRepSweep_Rotation::GDDShapeIsToAdd
749 (const TopoDS_Shape& aNewShape,
750 const TopoDS_Shape& aNewSubShape,
751 const TopoDS_Shape& aGenS,
752 const Sweep_NumShape& aDirS,
753 const Sweep_NumShape& aSubDirS )const
755 if ( aNewShape.ShapeType() == TopAbs_SOLID &&
756 aNewSubShape.ShapeType() == TopAbs_FACE &&
757 aGenS.ShapeType() == TopAbs_FACE &&
758 aDirS.Type() == TopAbs_EDGE &&
759 aSubDirS.Type() == TopAbs_VERTEX ){
760 return ( Abs(myAng - 2 * M_PI) > Precision::Angular() );
762 else if ( aNewShape.ShapeType() == TopAbs_FACE &&
763 aNewSubShape.ShapeType() == TopAbs_EDGE &&
764 aGenS.ShapeType() == TopAbs_EDGE &&
765 aDirS.Type() == TopAbs_EDGE &&
766 aSubDirS.Type() == TopAbs_VERTEX ){
768 GeomAdaptor_Surface AS(BRep_Tool::Surface(TopoDS::Face(aNewShape),Loc));
769 if (AS.GetType()==GeomAbs_Plane){
770 return ( Abs(myAng - 2 * M_PI) > Precision::Angular() );
773 return Standard_True;
777 return Standard_True;
782 //=======================================================================
783 //function : SeparatedWires
785 //=======================================================================
787 Standard_Boolean BRepSweep_Rotation::SeparatedWires
788 (const TopoDS_Shape& aNewShape,
789 const TopoDS_Shape& aNewSubShape,
790 const TopoDS_Shape& aGenS,
791 const TopoDS_Shape& aSubGenS,
792 const Sweep_NumShape& aDirS )const
794 if (aNewShape.ShapeType()==TopAbs_FACE &&
795 aNewSubShape.ShapeType()==TopAbs_EDGE &&
796 aGenS.ShapeType()==TopAbs_EDGE &&
797 aSubGenS.ShapeType()==TopAbs_VERTEX &&
798 aDirS.Type()==TopAbs_EDGE){
800 GeomAdaptor_Surface AS(BRep_Tool::Surface(TopoDS::Face(aNewShape),Loc));
801 if (AS.GetType()==GeomAbs_Plane){
802 return (Abs(myAng-2*M_PI) <= Precision::Angular());
805 return Standard_False;
809 return Standard_False;
813 //=======================================================================
814 //function : SplitShell
816 //=======================================================================
818 TopoDS_Shape BRepSweep_Rotation::SplitShell(const TopoDS_Shape& aNewShape)const
825 //=======================================================================
826 //function : HasShape
828 //=======================================================================
830 Standard_Boolean BRepSweep_Rotation::HasShape
831 (const TopoDS_Shape& aGenS,
832 const Sweep_NumShape& aDirS)const
834 if(aDirS.Type()==TopAbs_EDGE&&
835 aGenS.ShapeType()==TopAbs_EDGE){
836 // Verify that the edge has entrails
837 const TopoDS_Edge& anEdge = TopoDS::Edge(aGenS);
838 Standard_Boolean hasGeom = !BRep_Tool::Degenerated(anEdge);
840 { // The edge is not degenerated. Check if it has no curve
841 Standard_Real aPFirst, aPLast;
842 TopLoc_Location aLoc;
843 Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aLoc, aPFirst, aPLast);
844 hasGeom = !aCurve.IsNull();
846 return hasGeom && !IsInvariant(aGenS);
849 return Standard_True;
854 //=======================================================================
855 //function : IsInvariant
857 //=======================================================================
859 Standard_Boolean BRepSweep_Rotation::IsInvariant
860 (const TopoDS_Shape& aGenS)const
862 if(aGenS.ShapeType()==TopAbs_EDGE){
864 Standard_Real First,Last;
866 C = BRep_Tool::Curve(TopoDS::Edge(aGenS),Loc,First,Last);
867 if (C.IsNull() || C->DynamicType() == STANDARD_TYPE(Geom_Line)) {
868 TopoDS_Vertex V1, V2;
869 TopExp::Vertices(TopoDS::Edge(aGenS), V1, V2);
870 return ( IsInvariant(V1) && IsInvariant(V2));
873 return Standard_False;
876 else if(aGenS.ShapeType()==TopAbs_VERTEX){
877 gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aGenS));
878 gp_Lin Lin (myAxe.Location(), myAxe.Direction());
879 return ( Lin.Distance(P) <= BRep_Tool::Tolerance(TopoDS::Vertex(aGenS)));
882 return Standard_False;
885 //=======================================================================
888 //=======================================================================
890 Standard_Real BRepSweep_Rotation::Angle()const
895 //=======================================================================
898 //=======================================================================
900 gp_Ax1 BRepSweep_Rotation::Axe()const