0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / AppParCurves / AppParCurves_MultiBSpCurve.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
7fd59977 14
42cf5bc1 15
7fd59977 16#include <AppParCurves_HArray1OfMultiPoint.hxx>
42cf5bc1 17#include <AppParCurves_MultiBSpCurve.hxx>
18#include <AppParCurves_MultiCurve.hxx>
7fd59977 19#include <BSplCLib.hxx>
42cf5bc1 20#include <gp_Pnt.hxx>
21#include <gp_Pnt2d.hxx>
22#include <gp_Vec.hxx>
23#include <gp_Vec2d.hxx>
24#include <Standard_ConstructionError.hxx>
25#include <Standard_DimensionError.hxx>
26#include <Standard_OutOfRange.hxx>
27#include <TColgp_Array1OfPnt.hxx>
28#include <TColgp_Array1OfPnt2d.hxx>
7fd59977 29
30//=======================================================================
31//function : ComputeDegree
32//purpose :
33//=======================================================================
7fd59977 34static Standard_Integer ComputeDegree(const TColStd_Array1OfInteger& mults,
35 const Standard_Integer nbPoles)
36{
37 Standard_Integer i, sum = 0;
38 for (i = mults.Lower(); i <= mults.Upper(); i++) {
39 sum += mults(i);
40 }
41 return sum - nbPoles -1;
42}
43
44//=======================================================================
45//function : AppParCurves_MultiBSpCurve
46//purpose :
47//=======================================================================
48
d533dafb 49AppParCurves_MultiBSpCurve::AppParCurves_MultiBSpCurve()
50: myDegree(0)
51{
52}
7fd59977 53
54
55//=======================================================================
56//function : AppParCurves_MultiBSpCurve
57//purpose :
58//=======================================================================
59
60AppParCurves_MultiBSpCurve::AppParCurves_MultiBSpCurve
61 (const Standard_Integer NbPol):
d533dafb 62 AppParCurves_MultiCurve(NbPol),
63 myDegree(0)
7fd59977 64{
65}
66
67
68
69//=======================================================================
70//function : AppParCurves_MultiBSpCurve
71//purpose :
72//=======================================================================
73
74AppParCurves_MultiBSpCurve::AppParCurves_MultiBSpCurve
75 (const AppParCurves_Array1OfMultiPoint& tabMU,
76 const TColStd_Array1OfReal& Knots,
77 const TColStd_Array1OfInteger& Mults):
78 AppParCurves_MultiCurve(tabMU)
79{
80 myknots = new TColStd_HArray1OfReal(Knots.Lower(), Knots.Upper());
81 myknots->ChangeArray1() = Knots;
82 mymults = new TColStd_HArray1OfInteger(Mults.Lower(), Mults.Upper());
83 mymults->ChangeArray1() = Mults;
84 myDegree = ComputeDegree(Mults,NbPoles());
85}
86
87
88//=======================================================================
89//function : AppParCurves_MultiBSpCurve
90//purpose :
91//=======================================================================
92
93AppParCurves_MultiBSpCurve::AppParCurves_MultiBSpCurve
94 (const AppParCurves_MultiCurve& SC,
95 const TColStd_Array1OfReal& Knots,
96 const TColStd_Array1OfInteger& Mults):
97 AppParCurves_MultiCurve(SC)
98{
99 myknots = new TColStd_HArray1OfReal(Knots.Lower(), Knots.Upper());
100 myknots->ChangeArray1() = Knots;
101 mymults = new TColStd_HArray1OfInteger(Mults.Lower(), Mults.Upper());
102 mymults->ChangeArray1() = Mults;
103 myDegree = ComputeDegree(Mults,NbPoles());
104}
105
106
107//=======================================================================
108//function : SetKnots
109//purpose :
110//=======================================================================
111
112void AppParCurves_MultiBSpCurve::SetKnots(const TColStd_Array1OfReal& theKnots)
113{
114 myknots = new TColStd_HArray1OfReal(theKnots.Lower(), theKnots.Upper());
115 myknots->ChangeArray1() = theKnots;
116}
117
118//=======================================================================
119//function : SetMultiplicities
120//purpose :
121//=======================================================================
122
123void AppParCurves_MultiBSpCurve::SetMultiplicities(const TColStd_Array1OfInteger& theMults)
124{
125 mymults = new TColStd_HArray1OfInteger(theMults.Lower(), theMults.Upper());
126 mymults->ChangeArray1() = theMults;
127 myDegree = ComputeDegree(theMults,NbPoles());
128}
129
130
131//=======================================================================
132//function : Knots
133//purpose :
134//=======================================================================
135
136const TColStd_Array1OfReal& AppParCurves_MultiBSpCurve::Knots() const
137{
138 return myknots->Array1();
139}
140
141//=======================================================================
142//function : Multiplicities
143//purpose :
144//=======================================================================
145
146const TColStd_Array1OfInteger& AppParCurves_MultiBSpCurve::Multiplicities() const
147{
148 return mymults->Array1();
149}
150
151
152//=======================================================================
153//function : Degree
154//purpose :
155//=======================================================================
156
157Standard_Integer AppParCurves_MultiBSpCurve::Degree() const
158{
159 return myDegree;
160}
161
162
163//=======================================================================
164//function : Value
165//purpose :
166//=======================================================================
167
168void AppParCurves_MultiBSpCurve::Value (const Standard_Integer CuIndex,
169 const Standard_Real U, gp_Pnt& Pt) const {
170
171 if (Dimension(CuIndex) != 3) {
9775fa61 172 throw Standard_OutOfRange();
7fd59977 173 }
174
175 TColgp_Array1OfPnt TabPoles(1, tabPoint->Length());
176 Curve(CuIndex, TabPoles);
177
178 BSplCLib::D0(U,0,myDegree,Standard_False,TabPoles,BSplCLib::NoWeights(),
0e14656b 179 myknots->Array1(),&mymults->Array1(),Pt);
7fd59977 180}
181
182
183//=======================================================================
184//function : Value
185//purpose :
186//=======================================================================
187
188void AppParCurves_MultiBSpCurve::Value (const Standard_Integer CuIndex,
189 const Standard_Real U, gp_Pnt2d& Pt) const {
190
191 if (Dimension(CuIndex) != 2) {
9775fa61 192 throw Standard_OutOfRange();
7fd59977 193 }
194
195 TColgp_Array1OfPnt2d TabPoles(1, tabPoint->Length());
196 Curve(CuIndex, TabPoles);
197
198 BSplCLib::D0(U,0,myDegree,Standard_False,TabPoles,BSplCLib::NoWeights(),
0e14656b 199 myknots->Array1(),&mymults->Array1(),Pt);
7fd59977 200}
201
202
203//=======================================================================
204//function : D1
205//purpose :
206//=======================================================================
207
208void AppParCurves_MultiBSpCurve::D1 (const Standard_Integer CuIndex,
209 const Standard_Real U, gp_Pnt& Pt, gp_Vec& V1) const {
210 if (Dimension(CuIndex) != 3) {
9775fa61 211 throw Standard_OutOfRange();
7fd59977 212 }
213
214 TColgp_Array1OfPnt TabPoles(1, tabPoint->Length());
215 Curve(CuIndex, TabPoles);
216
217 BSplCLib::D1(U,0,myDegree,Standard_False,TabPoles,BSplCLib::NoWeights(),
0e14656b 218 myknots->Array1(),&mymults->Array1(),Pt,V1);
7fd59977 219}
220
221
222//=======================================================================
223//function : D2
224//purpose :
225//=======================================================================
226
227void AppParCurves_MultiBSpCurve::D2 (const Standard_Integer CuIndex,
228 const Standard_Real U,
229 gp_Pnt& Pt,
230 gp_Vec& V1,
231 gp_Vec& V2) const {
232 if (Dimension(CuIndex) != 3) {
9775fa61 233 throw Standard_OutOfRange();
7fd59977 234 }
235
236 TColgp_Array1OfPnt TabPoles(1, tabPoint->Length());
237 Curve(CuIndex, TabPoles);
238
239 BSplCLib::D2(U,0,myDegree,Standard_False,TabPoles,BSplCLib::NoWeights(),
0e14656b 240 myknots->Array1(),&mymults->Array1(),Pt,V1,V2);
7fd59977 241}
242
243
244//=======================================================================
245//function : D1
246//purpose :
247//=======================================================================
248
249void AppParCurves_MultiBSpCurve::D1 (const Standard_Integer CuIndex,
250 const Standard_Real U, gp_Pnt2d& Pt, gp_Vec2d& V1) const {
251 if (Dimension(CuIndex) != 2) {
9775fa61 252 throw Standard_OutOfRange();
7fd59977 253 }
254
255 TColgp_Array1OfPnt2d TabPoles(1, tabPoint->Length());
256 Curve(CuIndex, TabPoles);
257
258 BSplCLib::D1(U,0,myDegree,Standard_False,TabPoles,BSplCLib::NoWeights(),
0e14656b 259 myknots->Array1(),&mymults->Array1(),Pt,V1);
7fd59977 260}
261
262
263//=======================================================================
264//function : D2
265//purpose :
266//=======================================================================
267
268void AppParCurves_MultiBSpCurve::D2 (const Standard_Integer CuIndex,
269 const Standard_Real U,
270 gp_Pnt2d& Pt,
271 gp_Vec2d& V1,
272 gp_Vec2d& V2) const {
273 if (Dimension(CuIndex) != 2) {
9775fa61 274 throw Standard_OutOfRange();
7fd59977 275 }
276
277 TColgp_Array1OfPnt2d TabPoles(1, tabPoint->Length());
278 Curve(CuIndex, TabPoles);
279
280 BSplCLib::D2(U,0,myDegree,Standard_False,TabPoles,BSplCLib::NoWeights(),
0e14656b 281 myknots->Array1(),&mymults->Array1(),Pt,V1,V2);
7fd59977 282}
283
284
285
286//=======================================================================
287//function : Dump
288//purpose :
289//=======================================================================
290
291void AppParCurves_MultiBSpCurve::Dump(Standard_OStream& o) const
292{
04232180 293 o << "AppParCurves_MultiBSpCurve dump:" << std::endl;
294 o << " It contains " << NbCurves() << " BSpline curves "<< std::endl;
295 o << " The poles are: " << std::endl;
7fd59977 296/* for (Standard_Integer i = 1; i <= NbCurves(); i++) {
04232180 297 o << " Curve No. " << i << std::endl;
7fd59977 298 if (Dimension(i) == 3) {
299 for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
04232180 300 o << " Pole No. " << j << ": " << std::endl;
301 o << " Pole x = " << (tabPoint->Value(j)->Point(i)).X() << std::endl;
302 o << " Pole y = " << (tabPoint->Value(j)->Point(i)).Y() << std::endl;
303 o << " Pole z = " << (tabPoint->Value(j)->Point(i)).Z() << std::endl;
7fd59977 304 }
305 }
306 else {
307 for (Standard_Integer j = 1; j <= tabPoint->Length(); j++) {
04232180 308 o << " Pole No. " << j << ": " << std::endl;
309 o << " Pole x = " << (tabPoint->Value(j)->Point2d(i)).X() << std::endl;
310 o << " Pole y = " << (tabPoint->Value(j)->Point2d(i)).Y() << std::endl;
7fd59977 311 }
312 }
313 }
314*/
315}
316
317
318