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
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 <ShapeUpgrade_SplitSurfaceAngle.ixx>
18 #include <Geom_SurfaceOfRevolution.hxx>
19 #include <Geom_ConicalSurface.hxx>
20 #include <Geom_ToroidalSurface.hxx>
21 #include <Geom_CylindricalSurface.hxx>
22 #include <Geom_SphericalSurface.hxx>
23 #include <TColStd_HSequenceOfReal.hxx>
24 #include <ShapeExtend.hxx>
25 #include <Geom_RectangularTrimmedSurface.hxx>
26 #include <Geom_OffsetSurface.hxx>
27 #include <Precision.hxx>
29 //=======================================================================
30 //function : ShapeUpgrade_SplitSurfaceAngle
32 //=======================================================================
34 ShapeUpgrade_SplitSurfaceAngle::ShapeUpgrade_SplitSurfaceAngle (const Standard_Real MaxAngle)
36 myMaxAngle = MaxAngle;
39 //=======================================================================
40 //function : SetMaxAngle
42 //=======================================================================
44 void ShapeUpgrade_SplitSurfaceAngle::SetMaxAngle (const Standard_Real MaxAngle)
46 myMaxAngle = MaxAngle;
49 //=======================================================================
52 //=======================================================================
54 double ShapeUpgrade_SplitSurfaceAngle::MaxAngle () const
59 //=======================================================================
62 //=======================================================================
64 void ShapeUpgrade_SplitSurfaceAngle::Compute(const Standard_Boolean /*Segment*/)
66 Handle(Geom_Surface) S;
67 Standard_Real U1 = 0.,U2 = 0.;
68 Standard_Boolean isRect = Standard_False;
69 if(mySurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))){
70 Handle(Geom_RectangularTrimmedSurface) rts =
71 Handle(Geom_RectangularTrimmedSurface)::DownCast(mySurface);
72 isRect = Standard_True;
74 rts->Bounds(U1,U2,V1,V2);
75 S = rts->BasisSurface();
77 else if (mySurface->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
78 Handle(Geom_OffsetSurface) ofs =
79 Handle(Geom_OffsetSurface)::DownCast(mySurface);
80 S = ofs->BasisSurface();
85 if(S->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))||
86 S->IsKind(STANDARD_TYPE(Geom_ConicalSurface))||
87 S->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))||
88 S->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))||
89 S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
91 Standard_Real UFirst = myUSplitValues->Sequence().First();
92 Standard_Real ULast = myUSplitValues->Sequence().Last();
93 Standard_Real maxAngle = myMaxAngle; //maximal u length of segment
94 Standard_Real uLength = ULast-UFirst;
95 Standard_Integer nbSegments = Standard_Integer((uLength-Precision::Angular())/maxAngle)+1;
97 if(!isRect || !(uLength < maxAngle) || !((U2-U1) < maxAngle))
98 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2);
99 Standard_Real segAngle = uLength/nbSegments;
100 Standard_Real currAngle = segAngle+UFirst;
101 Handle(TColStd_HSequenceOfReal) splitValues = new TColStd_HSequenceOfReal;
102 for( Standard_Integer i = 1; i < nbSegments; i++, currAngle+=segAngle)
103 splitValues->Append(currAngle);
104 SetUSplitValues ( splitValues );