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.
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>
31 IMPLEMENT_STANDARD_RTTIEXT(ShapeUpgrade_SplitSurfaceAngle,ShapeUpgrade_SplitSurface)
33 //=======================================================================
34 //function : ShapeUpgrade_SplitSurfaceAngle
36 //=======================================================================
37 ShapeUpgrade_SplitSurfaceAngle::ShapeUpgrade_SplitSurfaceAngle (const Standard_Real MaxAngle)
39 myMaxAngle = MaxAngle;
42 //=======================================================================
43 //function : SetMaxAngle
45 //=======================================================================
47 void ShapeUpgrade_SplitSurfaceAngle::SetMaxAngle (const Standard_Real MaxAngle)
49 myMaxAngle = MaxAngle;
52 //=======================================================================
55 //=======================================================================
57 double ShapeUpgrade_SplitSurfaceAngle::MaxAngle () const
62 //=======================================================================
65 //=======================================================================
67 void ShapeUpgrade_SplitSurfaceAngle::Compute(const Standard_Boolean /*Segment*/)
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;
77 rts->Bounds(U1,U2,V1,V2);
78 S = rts->BasisSurface();
80 else if (mySurface->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
81 Handle(Geom_OffsetSurface) ofs =
82 Handle(Geom_OffsetSurface)::DownCast(mySurface);
83 S = ofs->BasisSurface();
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))) {
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;
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 );