0031035: Coding - uninitialized class fields reported by Visual Studio Code Analysis
[occt.git] / src / ShapeUpgrade / ShapeUpgrade_SplitSurfaceAngle.cxx
1 // Created on: 1999-05-06
2 // Created by: data exchange team
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Geom_ConicalSurface.hxx>
19 #include <Geom_CylindricalSurface.hxx>
20 #include <Geom_OffsetSurface.hxx>
21 #include <Geom_RectangularTrimmedSurface.hxx>
22 #include <Geom_SphericalSurface.hxx>
23 #include <Geom_SurfaceOfRevolution.hxx>
24 #include <Geom_ToroidalSurface.hxx>
25 #include <Precision.hxx>
26 #include <ShapeExtend.hxx>
27 #include <ShapeUpgrade_SplitSurfaceAngle.hxx>
28 #include <Standard_Type.hxx>
29 #include <TColStd_HSequenceOfReal.hxx>
30
31 IMPLEMENT_STANDARD_RTTIEXT(ShapeUpgrade_SplitSurfaceAngle,ShapeUpgrade_SplitSurface)
32
33 //=======================================================================
34 //function : ShapeUpgrade_SplitSurfaceAngle
35 //purpose  : 
36 //=======================================================================
37 ShapeUpgrade_SplitSurfaceAngle::ShapeUpgrade_SplitSurfaceAngle (const Standard_Real MaxAngle)
38 {
39   myMaxAngle = MaxAngle;
40 }
41
42 //=======================================================================
43 //function : SetMaxAngle
44 //purpose  : 
45 //=======================================================================
46
47 void ShapeUpgrade_SplitSurfaceAngle::SetMaxAngle (const Standard_Real MaxAngle)
48 {
49   myMaxAngle = MaxAngle;
50 }
51      
52 //=======================================================================
53 //function : MaxAngle
54 //purpose  : 
55 //=======================================================================
56
57 double ShapeUpgrade_SplitSurfaceAngle::MaxAngle () const
58 {
59   return myMaxAngle;
60 }
61      
62 //=======================================================================
63 //function : Compute
64 //purpose  : 
65 //=======================================================================
66
67 void ShapeUpgrade_SplitSurfaceAngle::Compute(const Standard_Boolean /*Segment*/)
68 {
69   Handle(Geom_Surface) S;
70   Standard_Real U1 = 0.,U2 = 0.;
71   Standard_Boolean isRect = Standard_False;
72   if(mySurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))){
73     Handle(Geom_RectangularTrimmedSurface) rts = 
74       Handle(Geom_RectangularTrimmedSurface)::DownCast(mySurface);
75     isRect = Standard_True;
76     Standard_Real V1,V2;
77     rts->Bounds(U1,U2,V1,V2);
78     S = rts->BasisSurface();
79   }
80   else if (mySurface->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
81     Handle(Geom_OffsetSurface) ofs = 
82       Handle(Geom_OffsetSurface)::DownCast(mySurface);
83     S = ofs->BasisSurface();
84   }
85   else 
86     S = mySurface;
87   
88   if(S->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))||
89      S->IsKind(STANDARD_TYPE(Geom_ConicalSurface))||
90      S->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))||
91      S->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))||
92      S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
93     
94     Standard_Real UFirst = myUSplitValues->Sequence().First();
95     Standard_Real ULast  = myUSplitValues->Sequence().Last();
96     Standard_Real maxAngle = myMaxAngle; //maximal u length of segment
97     Standard_Real uLength = ULast-UFirst;
98     Standard_Integer nbSegments = Standard_Integer((uLength-Precision::Angular())/maxAngle)+1;
99     if(nbSegments==1)
100       if(!isRect || !(uLength < maxAngle) || !((U2-U1) < maxAngle))
101         myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2);
102     Standard_Real segAngle = uLength/nbSegments;
103     Standard_Real currAngle = segAngle+UFirst;
104     Handle(TColStd_HSequenceOfReal) splitValues = new TColStd_HSequenceOfReal;
105     for( Standard_Integer i = 1; i < nbSegments; i++, currAngle+=segAngle)
106       splitValues->Append(currAngle);
107     SetUSplitValues ( splitValues );
108   }
109 }
110