69fb11c8d984a04486381d67797a38d48f2957ee
[occt.git] / src / GeomToStep / GeomToStep_MakeBoundedSurface.cxx
1 // Created on: 1993-06-22
2 // Created by: Martine LANGLOIS
3 // Copyright (c) 1993-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_BezierSurface.hxx>
19 #include <Geom_BoundedSurface.hxx>
20 #include <Geom_BSplineSurface.hxx>
21 #include <Geom_RectangularTrimmedSurface.hxx>
22 #include <GeomConvert.hxx>
23 #include <GeomToStep_MakeBoundedSurface.hxx>
24 #include <GeomToStep_MakeBSplineSurfaceWithKnots.hxx>
25 #include <GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface.hxx>
26 #include <GeomToStep_MakeRectangularTrimmedSurface.hxx>
27 #include <StdFail_NotDone.hxx>
28 #include <StepGeom_BoundedSurface.hxx>
29 #include <StepGeom_BSplineSurfaceWithKnots.hxx>
30 #include <StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface.hxx>
31 #include <StepGeom_RectangularTrimmedSurface.hxx>
32
33 //=============================================================================
34 // Creation d' une BoundedSurface de prostep a partir d' une BoundedSurface
35 // de Geom
36 //=============================================================================
37 GeomToStep_MakeBoundedSurface::GeomToStep_MakeBoundedSurface
38   ( const Handle(Geom_BoundedSurface)& S)
39 {
40   done = Standard_True;
41   if (S->IsKind(STANDARD_TYPE(Geom_BSplineSurface))) {
42     Handle(Geom_BSplineSurface) BS= Handle(Geom_BSplineSurface)::DownCast(S);
43     // UPDATE FMA 1-04-96
44     if (S->IsUPeriodic() || S->IsVPeriodic()) {
45       Handle(Geom_BSplineSurface) newBS = 
46         Handle(Geom_BSplineSurface)::DownCast(BS->Copy());
47       newBS->SetUNotPeriodic();
48       newBS->SetVNotPeriodic();
49       BS = newBS;
50     }
51     if ( BS->IsURational() || BS->IsVRational() ) {
52       GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface 
53         MkRatBSplineS(BS);
54       theBoundedSurface = MkRatBSplineS.Value();
55     }
56     else {
57       GeomToStep_MakeBSplineSurfaceWithKnots MkBSplineS(BS);
58       theBoundedSurface = MkBSplineS.Value();
59     }
60   }
61   else if (S->IsKind(STANDARD_TYPE(Geom_BezierSurface))) {
62     Handle(Geom_BezierSurface) Sur = Handle(Geom_BezierSurface)::DownCast(S);
63     Handle (Geom_BSplineSurface) BS = 
64       GeomConvert::SurfaceToBSplineSurface(Sur);
65     if ( BS->IsURational() || BS->IsVRational() ) {
66       GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface 
67         MkRatBSplineS(BS);
68       theBoundedSurface = MkRatBSplineS.Value();
69     }
70     else {
71       GeomToStep_MakeBSplineSurfaceWithKnots MkBSplineS(BS);
72       theBoundedSurface = MkBSplineS.Value();
73     }
74   }
75   else if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
76     Handle(Geom_RectangularTrimmedSurface) Sur = 
77       Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
78     GeomToStep_MakeRectangularTrimmedSurface MkRTSurf(Sur);
79     theBoundedSurface = MkRTSurf.Value();
80   }
81   else
82     done = Standard_False;
83 }        
84
85
86 //=============================================================================
87 // renvoi des valeurs
88 //=============================================================================
89
90 const Handle(StepGeom_BoundedSurface) &
91       GeomToStep_MakeBoundedSurface::Value() const
92 {
93   StdFail_NotDone_Raise_if(!done, "");
94   return theBoundedSurface;
95 }