0023258: Missing parenthesis
[occt.git] / src / IGESGeom / IGESGeom_BSplineCurve.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20 //--------------------------------------------------------------------
21 //--------------------------------------------------------------------
22
23 #include <IGESGeom_BSplineCurve.ixx>
24 #include <Standard_OutOfRange.hxx>
25 #include <gp_GTrsf.hxx>
26
27
28 IGESGeom_BSplineCurve::IGESGeom_BSplineCurve ()    {  }
29
30
31     void IGESGeom_BSplineCurve::Init
32   (const Standard_Integer anIndex,
33    const Standard_Integer aDegree, const Standard_Boolean aPlanar,
34    const Standard_Boolean aClosed, const Standard_Boolean aPolynom,
35    const Standard_Boolean aPeriodic, 
36    const Handle(TColStd_HArray1OfReal)& allKnots,
37    const Handle(TColStd_HArray1OfReal)& allWeights,
38    const Handle(TColgp_HArray1OfXYZ)& allPoles,
39    const Standard_Real aUmin, const Standard_Real aUmax,
40    const gp_XYZ& aNorm)
41 {
42   if (!allPoles.IsNull()) {
43     if (allPoles->Length() != allWeights->Length())
44       Standard_DimensionMismatch::Raise("IGESGeom_BSplineCurve : Init");
45     if (allKnots->Lower()   != -aDegree || allKnots->Upper()   != anIndex+1 ||
46         allWeights->Upper() !=  anIndex ||
47         allWeights->Lower() != 0        || allPoles->Lower() != 0)
48       Standard_DimensionMismatch::Raise("IGESGeom_BSplineCurve : Init");
49   }
50
51   theIndex     = anIndex;
52   theDegree    = aDegree;
53   isPlanar     = aPlanar;
54   isClosed     = aClosed;
55   isPolynomial = aPolynom;
56   isPeriodic   = aPeriodic;
57   theKnots     = allKnots; 
58   theWeights   = allWeights;
59   thePoles     = allPoles;
60   theUmin      = aUmin;
61   theUmax      = aUmax;
62   theNorm      = aNorm;
63   InitTypeAndForm(126,FormNumber());
64 // FormNumber  precises the shape  0-5
65 }
66
67     void  IGESGeom_BSplineCurve::SetFormNumber (const Standard_Integer form)
68 {
69   if (form < 0 || form > 5) Standard_OutOfRange::Raise
70     ("IGESGeom_BSplineCurve : SetFormNumber");
71   InitTypeAndForm(126,form);
72 }
73
74     Standard_Integer IGESGeom_BSplineCurve::UpperIndex () const
75 {
76   return theIndex;
77 }
78
79     Standard_Integer IGESGeom_BSplineCurve::Degree () const
80 {
81   return theDegree;
82 }
83
84     Standard_Boolean IGESGeom_BSplineCurve::IsPlanar () const
85 {
86   return isPlanar;
87 }
88
89     Standard_Boolean IGESGeom_BSplineCurve::IsClosed () const
90 {
91   return isClosed;
92 }
93
94     Standard_Boolean IGESGeom_BSplineCurve::IsPolynomial
95   (const Standard_Boolean flag) const
96 {
97   if (flag || theWeights.IsNull()) return isPolynomial;
98   Standard_Integer i, i1 = theWeights->Lower(), i2 = theWeights->Upper();
99   Standard_Real w0 = theWeights->Value(i1);
100   for (i = i1+1; i <= i2; i ++)
101     if (Abs (theWeights->Value(i) - w0) > 1.e-10) return Standard_False;
102   return Standard_True;
103 }
104
105     Standard_Boolean IGESGeom_BSplineCurve::IsPeriodic () const
106 {
107   return isPeriodic;
108 }
109
110     Standard_Integer IGESGeom_BSplineCurve::NbKnots () const
111 {
112   return (theKnots.IsNull() ? 0 : theKnots->Length());
113 }
114
115     Standard_Real IGESGeom_BSplineCurve::Knot
116   (const Standard_Integer anIndex) const
117 {
118   return theKnots->Value(anIndex);
119 }
120
121     Standard_Integer IGESGeom_BSplineCurve::NbPoles () const
122 {
123   return (thePoles.IsNull() ? 0 : thePoles->Length());
124 }
125
126     Standard_Real IGESGeom_BSplineCurve::Weight
127   (const Standard_Integer anIndex) const
128 {
129   return theWeights->Value(anIndex);
130 }
131
132     gp_Pnt IGESGeom_BSplineCurve::Pole (const Standard_Integer anIndex) const
133 {
134   gp_XYZ tempXYZ = thePoles->Value(anIndex);
135   gp_Pnt Pole(tempXYZ);
136   return Pole;
137 }
138
139     gp_Pnt IGESGeom_BSplineCurve::TransformedPole
140   (const Standard_Integer anIndex) const
141 {
142   gp_XYZ tempXYZ = thePoles->Value(anIndex);
143   if (HasTransf()) Location().Transforms(tempXYZ);
144   gp_Pnt Pole(tempXYZ);
145   return Pole;
146 }
147
148     Standard_Real IGESGeom_BSplineCurve::UMin () const
149 {
150   return theUmin;
151 }
152
153     Standard_Real IGESGeom_BSplineCurve::UMax () const
154 {
155   return theUmax;
156 }
157
158     gp_XYZ IGESGeom_BSplineCurve::Normal () const
159 {
160   return theNorm;
161 }