b311480e |
1 | // Created on: 1993-07-02 |
2 | // Created by: Martine LANGLOIS |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | //:n6 abv 15.02.99: S4132: adding translation of polyline |
22 | //:p0 abv 19.02.99: management of 'done' flag improved; trimmed_curve treated |
23 | |
24 | #include <StepToGeom_MakeBoundedCurve.ixx> |
25 | |
26 | #include <StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve.hxx> |
27 | #include <StepGeom_BSplineCurveWithKnots.hxx> |
28 | #include <StepGeom_BezierCurve.hxx> |
29 | #include <StepGeom_UniformCurve.hxx> |
30 | #include <StepGeom_UniformCurveAndRationalBSplineCurve.hxx> |
31 | #include <StepGeom_QuasiUniformCurve.hxx> |
32 | #include <StepGeom_QuasiUniformCurveAndRationalBSplineCurve.hxx> |
33 | #include <StepGeom_Polyline.hxx> |
34 | #include <StepGeom_TrimmedCurve.hxx> |
35 | #include <StepGeom_KnotType.hxx> |
36 | #include <StepToGeom_MakeBSplineCurve.hxx> |
37 | #include <StepGeom_Polyline.hxx> |
38 | #include <StepToGeom_MakePolyline.hxx> |
39 | #include <StepToGeom_MakeTrimmedCurve.hxx> |
40 | |
41 | #include <TColStd_HArray1OfInteger.hxx> |
42 | #include <TColStd_HArray1OfReal.hxx> |
43 | |
44 | //============================================================================= |
45 | // Creation d' une BoundedCurve de Geom a partir d' une BoundedCurve de Step |
46 | //============================================================================= |
47 | |
48 | Standard_Boolean StepToGeom_MakeBoundedCurve::Convert |
49 | (const Handle(StepGeom_BoundedCurve)& SC, |
50 | Handle(Geom_BoundedCurve)& CC) |
51 | { |
52 | if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve))) { |
53 | const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) |
54 | Bspli = Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)::DownCast(SC); |
55 | return StepToGeom_MakeBSplineCurve::Convert(Bspli,*((Handle(Geom_BSplineCurve)*)&CC)); |
56 | } |
57 | if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnots))) { |
58 | const Handle(StepGeom_BSplineCurveWithKnots) |
59 | Bspli = Handle(StepGeom_BSplineCurveWithKnots)::DownCast(SC); |
60 | return StepToGeom_MakeBSplineCurve::Convert(Bspli,*((Handle(Geom_BSplineCurve)*)&CC)); |
61 | } |
62 | if (SC->IsKind(STANDARD_TYPE(StepGeom_TrimmedCurve))) { |
63 | const Handle(StepGeom_TrimmedCurve) L = Handle(StepGeom_TrimmedCurve)::DownCast(SC); |
64 | return StepToGeom_MakeTrimmedCurve::Convert(L,*((Handle(Geom_TrimmedCurve)*)&CC)); |
65 | } |
66 | // STEP BezierCurve, UniformCurve and QuasiUniformCurve are transformed into |
67 | // STEP BSplineCurve before being mapped onto CAS.CADE/SF |
68 | if (SC->IsKind(STANDARD_TYPE(StepGeom_BezierCurve))) { |
69 | const Handle(StepGeom_BezierCurve) BzC = Handle(StepGeom_BezierCurve)::DownCast(SC); |
70 | const Handle(StepGeom_BSplineCurveWithKnots) BSPL = new StepGeom_BSplineCurveWithKnots; |
71 | BSPL->SetDegree(BzC->Degree()); |
72 | BSPL->SetControlPointsList(BzC->ControlPointsList()); |
73 | BSPL->SetCurveForm(BzC->CurveForm()); |
74 | BSPL->SetClosedCurve(BzC->ClosedCurve()); |
75 | BSPL->SetSelfIntersect(BzC->SelfIntersect()); |
76 | // Compute Knots and KnotsMultiplicity |
77 | const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,2); |
78 | const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,2); |
79 | Kmult->SetValue(1, BzC->Degree() + 1); |
80 | Kmult->SetValue(2, BzC->Degree() + 1); |
81 | Knots->SetValue(1, 0.); |
82 | Knots->SetValue(2, 1.); |
83 | BSPL->SetKnotMultiplicities(Kmult); |
84 | BSPL->SetKnots(Knots); |
85 | return StepToGeom_MakeBSplineCurve::Convert(BSPL,*((Handle(Geom_BSplineCurve)*)&CC)); |
86 | } |
87 | if (SC->IsKind(STANDARD_TYPE(StepGeom_UniformCurve))) { |
88 | //#ifdef DEBUG |
89 | // cout << "Warning : converting UniformCurve onto BSplineCurveWithKnots" << endl; |
90 | //#endif |
91 | const Handle(StepGeom_UniformCurve) UC = Handle(StepGeom_UniformCurve)::DownCast(SC); |
92 | const Handle(StepGeom_BSplineCurveWithKnots) BSPL = new StepGeom_BSplineCurveWithKnots; |
93 | BSPL->SetDegree(UC->Degree()); |
94 | BSPL->SetControlPointsList(UC->ControlPointsList()); |
95 | BSPL->SetCurveForm(UC->CurveForm()); |
96 | BSPL->SetClosedCurve(UC->ClosedCurve()); |
97 | BSPL->SetSelfIntersect(UC->SelfIntersect()); |
98 | // Compute Knots and KnotsMultiplicity |
99 | const Standard_Integer nbK = BSPL->NbControlPointsList() + BSPL->Degree() + 1; |
100 | const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,nbK); |
101 | const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,nbK); |
102 | for (Standard_Integer iUC = 1 ; iUC <= nbK ; iUC ++) { |
103 | Kmult->SetValue(iUC, 1); |
104 | Knots->SetValue(iUC, iUC - 1.); |
105 | } |
106 | BSPL->SetKnotMultiplicities(Kmult); |
107 | BSPL->SetKnots(Knots); |
108 | return StepToGeom_MakeBSplineCurve::Convert(BSPL,*((Handle(Geom_BSplineCurve)*)&CC)); |
109 | } |
110 | if (SC->IsKind(STANDARD_TYPE(StepGeom_QuasiUniformCurve))) { |
111 | //#ifdef DEBUG |
112 | // cout << "Warning : converting QuasiUniformCurve onto BSplineCurveWithKnots" << endl; |
113 | //#endif |
114 | const Handle(StepGeom_QuasiUniformCurve) QUC = |
115 | Handle(StepGeom_QuasiUniformCurve)::DownCast(SC); |
116 | const Handle(StepGeom_BSplineCurveWithKnots) BSPL = new StepGeom_BSplineCurveWithKnots; |
117 | BSPL->SetDegree(QUC->Degree()); |
118 | BSPL->SetControlPointsList(QUC->ControlPointsList()); |
119 | BSPL->SetCurveForm(QUC->CurveForm()); |
120 | BSPL->SetClosedCurve(QUC->ClosedCurve()); |
121 | BSPL->SetSelfIntersect(QUC->SelfIntersect()); |
122 | // Compute Knots and KnotsMultiplicity |
123 | const Standard_Integer nbK = BSPL->NbControlPointsList() - BSPL->Degree() + 1; |
124 | const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,nbK); |
125 | const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,nbK); |
126 | for (Standard_Integer iQUC = 1 ; iQUC <= nbK ; iQUC ++) { |
127 | Kmult->SetValue(iQUC, 1); |
128 | Knots->SetValue(iQUC, iQUC - 1.); |
129 | } |
130 | Kmult->SetValue(1, BSPL->Degree() + 1); |
131 | Kmult->SetValue(nbK, BSPL->Degree() + 1); |
132 | BSPL->SetKnotMultiplicities(Kmult); |
133 | BSPL->SetKnots(Knots); |
134 | return StepToGeom_MakeBSplineCurve::Convert(BSPL,*((Handle(Geom_BSplineCurve)*)&CC)); |
135 | } |
136 | if (SC->IsKind(STANDARD_TYPE(StepGeom_UniformCurveAndRationalBSplineCurve))) { |
137 | //#ifdef DEBUG |
138 | // cout << "Warning : converting Rational UniformCurve onto BSplineCurveWithKnots" << endl; |
139 | //#endif |
140 | const Handle(StepGeom_UniformCurveAndRationalBSplineCurve) RUC = |
141 | Handle(StepGeom_UniformCurveAndRationalBSplineCurve)::DownCast(SC); |
142 | const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) RBSPL = |
143 | new StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve; |
144 | // Compute Knots and KnotsMultiplicity |
145 | const Standard_Integer nbK = RUC->NbControlPointsList() + RUC->Degree() + 1; |
146 | const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,nbK); |
147 | const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,nbK); |
148 | for (Standard_Integer iUC = 1 ; iUC <= nbK ; iUC ++) { |
149 | Kmult->SetValue(iUC, 1); |
150 | Knots->SetValue(iUC, iUC - 1.); |
151 | } |
152 | // Initialize the BSplineCurveWithKnotsAndRationalBSplineCurve |
153 | RBSPL->Init(RUC->Name(), RUC->Degree(), RUC->ControlPointsList(), RUC->CurveForm(), |
154 | RUC->ClosedCurve(), RUC->SelfIntersect(), Kmult, Knots, StepGeom_ktUnspecified, |
155 | RUC->WeightsData()); |
156 | return StepToGeom_MakeBSplineCurve::Convert(RBSPL,*((Handle(Geom_BSplineCurve)*)&CC)); |
157 | } |
158 | if (SC->IsKind(STANDARD_TYPE(StepGeom_QuasiUniformCurveAndRationalBSplineCurve))) { |
159 | //#ifdef DEBUG |
160 | // cout << "Warning : converting Rational QuasiUniformCurve onto BSplineCurveWithKnots" << endl; |
161 | //#endif |
162 | const Handle(StepGeom_QuasiUniformCurveAndRationalBSplineCurve) RQUC = |
163 | Handle(StepGeom_QuasiUniformCurveAndRationalBSplineCurve)::DownCast(SC); |
164 | const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) RBSPL = |
165 | new StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve; |
166 | // Compute Knots and KnotsMultiplicity |
167 | const Standard_Integer nbK = RQUC->NbControlPointsList() - RQUC->Degree() + 1; |
168 | const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,nbK); |
169 | const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,nbK); |
170 | for (Standard_Integer iRQUC = 1 ; iRQUC <= nbK ; iRQUC ++) { |
171 | Kmult->SetValue(iRQUC, 1); |
172 | Knots->SetValue(iRQUC, iRQUC - 1.); |
173 | } |
174 | Kmult->SetValue(1, RQUC->Degree() + 1); |
175 | Kmult->SetValue(nbK, RQUC->Degree() + 1); |
176 | // Initialize the BSplineCurveWithKnotsAndRationalBSplineCurve |
177 | RBSPL->Init(RQUC->Name(), RQUC->Degree(), RQUC->ControlPointsList(), RQUC->CurveForm(), |
178 | RQUC->ClosedCurve(), RQUC->SelfIntersect(), Kmult, Knots, StepGeom_ktUnspecified, |
179 | RQUC->WeightsData()); |
180 | return StepToGeom_MakeBSplineCurve::Convert(RBSPL,*((Handle(Geom_BSplineCurve)*)&CC)); |
181 | } |
182 | if (SC->IsKind(STANDARD_TYPE(StepGeom_Polyline))) { //:n6 abv 15 Feb 99 |
183 | const Handle(StepGeom_Polyline) PL = Handle(StepGeom_Polyline)::DownCast (SC); |
184 | return StepToGeom_MakePolyline::Convert(PL,*((Handle(Geom_BSplineCurve)*)&CC)); |
185 | } |
186 | return Standard_False; |
187 | } |