1 // File: ShapeUpgrade_SplitSurfaceAngle.cxx
2 // Created: Thu May 6 10:51:57 1999
3 // Author: data exchange team
4 // <det@friendox.nnov.matra-dtv.fr>
7 #include <ShapeUpgrade_SplitSurfaceAngle.ixx>
8 #include <Geom_SurfaceOfRevolution.hxx>
9 #include <Geom_ConicalSurface.hxx>
10 #include <Geom_ToroidalSurface.hxx>
11 #include <Geom_CylindricalSurface.hxx>
12 #include <Geom_SphericalSurface.hxx>
13 #include <TColStd_HSequenceOfReal.hxx>
14 #include <ShapeExtend.hxx>
15 #include <Geom_RectangularTrimmedSurface.hxx>
16 #include <Geom_OffsetSurface.hxx>
17 #include <Precision.hxx>
19 //=======================================================================
20 //function : ShapeUpgrade_SplitSurfaceAngle
22 //=======================================================================
24 ShapeUpgrade_SplitSurfaceAngle::ShapeUpgrade_SplitSurfaceAngle (const Standard_Real MaxAngle)
26 myMaxAngle = MaxAngle;
29 //=======================================================================
30 //function : SetMaxAngle
32 //=======================================================================
34 void ShapeUpgrade_SplitSurfaceAngle::SetMaxAngle (const Standard_Real MaxAngle)
36 myMaxAngle = MaxAngle;
39 //=======================================================================
42 //=======================================================================
44 double ShapeUpgrade_SplitSurfaceAngle::MaxAngle () const
49 //=======================================================================
52 //=======================================================================
54 void ShapeUpgrade_SplitSurfaceAngle::Compute(const Standard_Boolean /*Segment*/)
56 Handle(Geom_Surface) S;
58 Standard_Boolean isRect = Standard_False;
59 if(mySurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))){
60 Handle(Geom_RectangularTrimmedSurface) rts =
61 Handle(Geom_RectangularTrimmedSurface)::DownCast(mySurface);
62 isRect = Standard_True;
64 rts->Bounds(U1,U2,V1,V2);
65 S = rts->BasisSurface();
67 else if (mySurface->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
68 Handle(Geom_OffsetSurface) ofs =
69 Handle(Geom_OffsetSurface)::DownCast(mySurface);
70 S = ofs->BasisSurface();
75 if(S->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))||
76 S->IsKind(STANDARD_TYPE(Geom_ConicalSurface))||
77 S->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))||
78 S->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))||
79 S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
81 Standard_Real UFirst = myUSplitValues->Sequence().First();
82 Standard_Real ULast = myUSplitValues->Sequence().Last();
83 Standard_Real maxAngle = myMaxAngle; //maximal u length of segment
84 Standard_Real uLength = ULast-UFirst;
85 Standard_Integer nbSegments = Standard_Integer((uLength-Precision::Angular())/maxAngle)+1;
87 if(!isRect || !(uLength < maxAngle) || !((U2-U1) < maxAngle))
88 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2);
89 Standard_Real segAngle = uLength/nbSegments;
90 Standard_Real currAngle = segAngle+UFirst;
91 Handle(TColStd_HSequenceOfReal) splitValues = new TColStd_HSequenceOfReal;
92 for( Standard_Integer i = 1; i < nbSegments; i++, currAngle+=segAngle)
93 splitValues->Append(currAngle);
94 SetUSplitValues ( splitValues );