0025266: Debug statements in the source are getting flushed on to the console
[occt.git] / src / GeomToStep / GeomToStep_MakeBoundedCurve.cxx
1 // Created on: 1993-06-21
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 #include <GeomToStep_MakeBoundedCurve.ixx>
18 #include <StdFail_NotDone.hxx>
19 #include <StepGeom_BoundedCurve.hxx>
20 #include <GeomToStep_MakeBoundedCurve.hxx>
21 #include <Geom_BSplineCurve.hxx>
22 #include <Geom_BezierCurve.hxx>
23 #include <Geom2d_BSplineCurve.hxx>
24 #include <Geom2d_BezierCurve.hxx>
25 #include <GeomConvert.hxx>
26 #include <Geom2dConvert.hxx>
27 #include <GeomToStep_MakeBSplineCurveWithKnots.hxx>
28 #include <GeomToStep_MakeBSplineCurveWithKnotsAndRationalBSplineCurve.hxx>
29
30
31 //=============================================================================
32 // Creation d' une BoundedCurve de prostep a partir d' une BoundedCurve de Geom
33 //=============================================================================
34
35 GeomToStep_MakeBoundedCurve::GeomToStep_MakeBoundedCurve ( const Handle(Geom_BoundedCurve)& C)
36 {
37   done = Standard_True;
38
39   if (C->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
40     Handle(Geom_BSplineCurve) Bspli = Handle(Geom_BSplineCurve)::DownCast(C);
41     // UPDATE FMA 1-04-96
42     if (C->IsPeriodic()) {
43       Handle(Geom_BSplineCurve) newBspli = 
44         Handle(Geom_BSplineCurve)::DownCast(Bspli->Copy());
45       newBspli->SetNotPeriodic();
46       Bspli = newBspli;
47     }
48     if ( Bspli->IsRational() ) {
49       GeomToStep_MakeBSplineCurveWithKnotsAndRationalBSplineCurve MkRatBSplineC(Bspli);
50       theBoundedCurve = MkRatBSplineC.Value();
51     }
52     else {
53       GeomToStep_MakeBSplineCurveWithKnots MkBSplineC(Bspli);
54       theBoundedCurve = MkBSplineC.Value();
55     }
56   }
57   else if (C->IsKind(STANDARD_TYPE(Geom_BezierCurve))) {
58     Handle(Geom_BezierCurve) Cur = Handle(Geom_BezierCurve)::DownCast(C);
59     Handle(Geom_BSplineCurve) Bspli = GeomConvert::CurveToBSplineCurve(Cur);
60     if ( Bspli->IsRational() ) {
61       GeomToStep_MakeBSplineCurveWithKnotsAndRationalBSplineCurve MkRatBSplineC(Bspli);
62       theBoundedCurve = MkRatBSplineC.Value();
63     }
64     else {
65       GeomToStep_MakeBSplineCurveWithKnots MkBSplineC(Bspli);
66       theBoundedCurve = MkBSplineC.Value();
67     }
68   }
69   else {
70 #ifdef GEOMTOSTEP_DEB
71     cout<<"MakeBoundedCurve, type : "<<C->DynamicType()->Name()<<" not processed"<<endl;
72 #endif
73     done = Standard_False;
74   }
75 }
76          
77 //=============================================================================
78 // Creation d' une BoundedCurve de prostep a partir d' une BoundedCurve de
79 // Geom2d
80 //=============================================================================
81
82 GeomToStep_MakeBoundedCurve::GeomToStep_MakeBoundedCurve ( const Handle(Geom2d_BoundedCurve)& C)
83 {
84   done = Standard_True;
85   if (C->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve)))
86     {
87       Handle(Geom2d_BSplineCurve) Bspli = 
88         Handle(Geom2d_BSplineCurve)::DownCast(C);
89       // UPDATE FMA 1-04-96
90       if (C->IsPeriodic()) {
91         Handle(Geom2d_BSplineCurve) newBspli = 
92           Handle(Geom2d_BSplineCurve)::DownCast(Bspli->Copy());
93         newBspli->SetNotPeriodic();
94         Bspli = newBspli;
95       }
96       if ( Bspli->IsRational() ) {
97         GeomToStep_MakeBSplineCurveWithKnotsAndRationalBSplineCurve MkRatBSplineC(Bspli);
98         theBoundedCurve = MkRatBSplineC.Value();
99       }
100       else {
101         GeomToStep_MakeBSplineCurveWithKnots MkBSplineC(Bspli);
102         theBoundedCurve = MkBSplineC.Value();
103       }
104     }
105   else if (C->IsKind(STANDARD_TYPE(Geom2d_BezierCurve))) {
106     Handle(Geom2d_BezierCurve) Cur = Handle(Geom2d_BezierCurve)::DownCast(C);
107     Handle(Geom2d_BSplineCurve) Bspli = 
108       Geom2dConvert::CurveToBSplineCurve(Cur);
109     GeomToStep_MakeBSplineCurveWithKnots MkBSplineC(Bspli);
110     theBoundedCurve = MkBSplineC.Value();
111     }
112   else
113     done = Standard_False;
114   
115 }
116
117 //=============================================================================
118 // renvoi des valeurs
119 //=============================================================================
120
121 const Handle(StepGeom_BoundedCurve) &
122       GeomToStep_MakeBoundedCurve::Value() const
123 {
124   StdFail_NotDone_Raise_if(!done == Standard_True,"");
125   return theBoundedCurve;
126 }