0029915: Porting to VC 2017 : Regressions in Modeling Algorithms on VC 2017
[occt.git] / src / GeomToStep / GeomToStep_MakeBoundedCurve.cxx
CommitLineData
b311480e 1// Created on: 1993-06-21
2// Created by: Martine LANGLOIS
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
7fd59977 18#include <Geom2d_BezierCurve.hxx>
42cf5bc1 19#include <Geom2d_BoundedCurve.hxx>
20#include <Geom2d_BSplineCurve.hxx>
7fd59977 21#include <Geom2dConvert.hxx>
42cf5bc1 22#include <Geom_BezierCurve.hxx>
23#include <Geom_BoundedCurve.hxx>
24#include <Geom_BSplineCurve.hxx>
25#include <GeomConvert.hxx>
26#include <GeomToStep_MakeBoundedCurve.hxx>
7fd59977 27#include <GeomToStep_MakeBSplineCurveWithKnots.hxx>
28#include <GeomToStep_MakeBSplineCurveWithKnotsAndRationalBSplineCurve.hxx>
42cf5bc1 29#include <StdFail_NotDone.hxx>
30#include <StepGeom_BoundedCurve.hxx>
c04c30b3 31#include <StepGeom_BSplineCurveWithKnots.hxx>
42cf5bc1 32#include <StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve.hxx>
7fd59977 33
34//=============================================================================
35// Creation d' une BoundedCurve de prostep a partir d' une BoundedCurve de Geom
36//=============================================================================
7fd59977 37GeomToStep_MakeBoundedCurve::GeomToStep_MakeBoundedCurve ( const Handle(Geom_BoundedCurve)& C)
38{
39 done = Standard_True;
40
41 if (C->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
42 Handle(Geom_BSplineCurve) Bspli = Handle(Geom_BSplineCurve)::DownCast(C);
43 // UPDATE FMA 1-04-96
44 if (C->IsPeriodic()) {
45 Handle(Geom_BSplineCurve) newBspli =
46 Handle(Geom_BSplineCurve)::DownCast(Bspli->Copy());
47 newBspli->SetNotPeriodic();
48 Bspli = newBspli;
49 }
50 if ( Bspli->IsRational() ) {
51 GeomToStep_MakeBSplineCurveWithKnotsAndRationalBSplineCurve MkRatBSplineC(Bspli);
52 theBoundedCurve = MkRatBSplineC.Value();
53 }
54 else {
55 GeomToStep_MakeBSplineCurveWithKnots MkBSplineC(Bspli);
56 theBoundedCurve = MkBSplineC.Value();
57 }
58 }
59 else if (C->IsKind(STANDARD_TYPE(Geom_BezierCurve))) {
60 Handle(Geom_BezierCurve) Cur = Handle(Geom_BezierCurve)::DownCast(C);
61 Handle(Geom_BSplineCurve) Bspli = GeomConvert::CurveToBSplineCurve(Cur);
62 if ( Bspli->IsRational() ) {
63 GeomToStep_MakeBSplineCurveWithKnotsAndRationalBSplineCurve MkRatBSplineC(Bspli);
64 theBoundedCurve = MkRatBSplineC.Value();
65 }
66 else {
67 GeomToStep_MakeBSplineCurveWithKnots MkBSplineC(Bspli);
68 theBoundedCurve = MkBSplineC.Value();
69 }
70 }
71 else {
0797d9d3 72#ifdef OCCT_DEBUG
7fd59977 73 cout<<"MakeBoundedCurve, type : "<<C->DynamicType()->Name()<<" not processed"<<endl;
74#endif
75 done = Standard_False;
76 }
77}
78
79//=============================================================================
80// Creation d' une BoundedCurve de prostep a partir d' une BoundedCurve de
81// Geom2d
82//=============================================================================
83
84GeomToStep_MakeBoundedCurve::GeomToStep_MakeBoundedCurve ( const Handle(Geom2d_BoundedCurve)& C)
85{
86 done = Standard_True;
87 if (C->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve)))
88 {
89 Handle(Geom2d_BSplineCurve) Bspli =
90 Handle(Geom2d_BSplineCurve)::DownCast(C);
91 // UPDATE FMA 1-04-96
92 if (C->IsPeriodic()) {
93 Handle(Geom2d_BSplineCurve) newBspli =
94 Handle(Geom2d_BSplineCurve)::DownCast(Bspli->Copy());
95 newBspli->SetNotPeriodic();
96 Bspli = newBspli;
97 }
98 if ( Bspli->IsRational() ) {
99 GeomToStep_MakeBSplineCurveWithKnotsAndRationalBSplineCurve MkRatBSplineC(Bspli);
100 theBoundedCurve = MkRatBSplineC.Value();
101 }
102 else {
103 GeomToStep_MakeBSplineCurveWithKnots MkBSplineC(Bspli);
104 theBoundedCurve = MkBSplineC.Value();
105 }
106 }
107 else if (C->IsKind(STANDARD_TYPE(Geom2d_BezierCurve))) {
108 Handle(Geom2d_BezierCurve) Cur = Handle(Geom2d_BezierCurve)::DownCast(C);
109 Handle(Geom2d_BSplineCurve) Bspli =
110 Geom2dConvert::CurveToBSplineCurve(Cur);
111 GeomToStep_MakeBSplineCurveWithKnots MkBSplineC(Bspli);
112 theBoundedCurve = MkBSplineC.Value();
113 }
114 else
115 done = Standard_False;
116
117}
118
119//=============================================================================
120// renvoi des valeurs
121//=============================================================================
122
123const Handle(StepGeom_BoundedCurve) &
124 GeomToStep_MakeBoundedCurve::Value() const
125{
2d2b3d53 126 StdFail_NotDone_Raise_if (!done, "GeomToStep_MakeBoundedCurve::Value() - no result");
7fd59977 127 return theBoundedCurve;
128}