0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / ShapeUpgrade / ShapeUpgrade_SplitSurfaceAngle.cxx
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>
5
6
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>
18
19 //=======================================================================
20 //function : ShapeUpgrade_SplitSurfaceAngle
21 //purpose  : 
22 //=======================================================================
23
24 ShapeUpgrade_SplitSurfaceAngle::ShapeUpgrade_SplitSurfaceAngle (const Standard_Real MaxAngle)
25 {
26   myMaxAngle = MaxAngle;
27 }
28
29 //=======================================================================
30 //function : SetMaxAngle
31 //purpose  : 
32 //=======================================================================
33
34 void ShapeUpgrade_SplitSurfaceAngle::SetMaxAngle (const Standard_Real MaxAngle)
35 {
36   myMaxAngle = MaxAngle;
37 }
38      
39 //=======================================================================
40 //function : MaxAngle
41 //purpose  : 
42 //=======================================================================
43
44 double ShapeUpgrade_SplitSurfaceAngle::MaxAngle () const
45 {
46   return myMaxAngle;
47 }
48      
49 //=======================================================================
50 //function : Compute
51 //purpose  : 
52 //=======================================================================
53
54 void ShapeUpgrade_SplitSurfaceAngle::Compute(const Standard_Boolean /*Segment*/)
55 {
56   Handle(Geom_Surface) S;
57   Standard_Real U1,U2;
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;
63     Standard_Real V1,V2;
64     rts->Bounds(U1,U2,V1,V2);
65     S = rts->BasisSurface();
66   }
67   else if (mySurface->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
68     Handle(Geom_OffsetSurface) ofs = 
69       Handle(Geom_OffsetSurface)::DownCast(mySurface);
70     S = ofs->BasisSurface();
71   }
72   else 
73     S = mySurface;
74   
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))) {
80     
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;
86     if(nbSegments==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 );
95   }
96 }
97