0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / IGESGeom / IGESGeom_BSplineCurve.cxx
CommitLineData
b311480e 1// Created by: CKY / Contract Toubro-Larsen
2// Copyright (c) 1993-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
7fd59977 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
7fd59977 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
16//--------------------------------------------------------------------
7fd59977 17//--------------------------------------------------------------------
18
7fd59977 19#include <gp_GTrsf.hxx>
42cf5bc1 20#include <gp_Pnt.hxx>
21#include <gp_XYZ.hxx>
22#include <IGESGeom_BSplineCurve.hxx>
23#include <Standard_DimensionMismatch.hxx>
24#include <Standard_OutOfRange.hxx>
25#include <Standard_Type.hxx>
7fd59977 26
92efcf78 27IMPLEMENT_STANDARD_RTTIEXT(IGESGeom_BSplineCurve,IGESData_IGESEntity)
28
b311480e 29IGESGeom_BSplineCurve::IGESGeom_BSplineCurve () { }
7fd59977 30
31
32 void IGESGeom_BSplineCurve::Init
33 (const Standard_Integer anIndex,
34 const Standard_Integer aDegree, const Standard_Boolean aPlanar,
35 const Standard_Boolean aClosed, const Standard_Boolean aPolynom,
36 const Standard_Boolean aPeriodic,
37 const Handle(TColStd_HArray1OfReal)& allKnots,
38 const Handle(TColStd_HArray1OfReal)& allWeights,
39 const Handle(TColgp_HArray1OfXYZ)& allPoles,
40 const Standard_Real aUmin, const Standard_Real aUmax,
41 const gp_XYZ& aNorm)
42{
de07af82 43 if (!allPoles.IsNull())
44 {
45 if (allKnots->Lower() != -aDegree
46 || allKnots->Upper() != anIndex + 1
47 || allPoles->Lower() != 0)
48 {
49 throw Standard_DimensionMismatch ("IGESGeom_BSplineCurve : Init");
50 }
51 if (!allWeights.IsNull())
52 {
53 if (allPoles->Length() != allWeights->Length()
54 || allWeights->Upper() != anIndex
55 || allWeights->Lower() != 0)
56 {
57 throw Standard_DimensionMismatch ("IGESGeom_BSplineCurve : Init");
58 }
59 }
7fd59977 60 }
61
62 theIndex = anIndex;
63 theDegree = aDegree;
64 isPlanar = aPlanar;
65 isClosed = aClosed;
66 isPolynomial = aPolynom;
67 isPeriodic = aPeriodic;
68 theKnots = allKnots;
69 theWeights = allWeights;
70 thePoles = allPoles;
71 theUmin = aUmin;
72 theUmax = aUmax;
73 theNorm = aNorm;
74 InitTypeAndForm(126,FormNumber());
75// FormNumber precises the shape 0-5
76}
77
78 void IGESGeom_BSplineCurve::SetFormNumber (const Standard_Integer form)
79{
9775fa61 80 if (form < 0 || form > 5) throw Standard_OutOfRange("IGESGeom_BSplineCurve : SetFormNumber");
7fd59977 81 InitTypeAndForm(126,form);
82}
83
84 Standard_Integer IGESGeom_BSplineCurve::UpperIndex () const
85{
86 return theIndex;
87}
88
89 Standard_Integer IGESGeom_BSplineCurve::Degree () const
90{
91 return theDegree;
92}
93
94 Standard_Boolean IGESGeom_BSplineCurve::IsPlanar () const
95{
96 return isPlanar;
97}
98
99 Standard_Boolean IGESGeom_BSplineCurve::IsClosed () const
100{
101 return isClosed;
102}
103
104 Standard_Boolean IGESGeom_BSplineCurve::IsPolynomial
105 (const Standard_Boolean flag) const
106{
107 if (flag || theWeights.IsNull()) return isPolynomial;
108 Standard_Integer i, i1 = theWeights->Lower(), i2 = theWeights->Upper();
109 Standard_Real w0 = theWeights->Value(i1);
110 for (i = i1+1; i <= i2; i ++)
111 if (Abs (theWeights->Value(i) - w0) > 1.e-10) return Standard_False;
112 return Standard_True;
113}
114
115 Standard_Boolean IGESGeom_BSplineCurve::IsPeriodic () const
116{
117 return isPeriodic;
118}
119
120 Standard_Integer IGESGeom_BSplineCurve::NbKnots () const
121{
122 return (theKnots.IsNull() ? 0 : theKnots->Length());
123}
124
125 Standard_Real IGESGeom_BSplineCurve::Knot
126 (const Standard_Integer anIndex) const
127{
128 return theKnots->Value(anIndex);
129}
130
131 Standard_Integer IGESGeom_BSplineCurve::NbPoles () const
132{
133 return (thePoles.IsNull() ? 0 : thePoles->Length());
134}
135
136 Standard_Real IGESGeom_BSplineCurve::Weight
137 (const Standard_Integer anIndex) const
138{
139 return theWeights->Value(anIndex);
140}
141
142 gp_Pnt IGESGeom_BSplineCurve::Pole (const Standard_Integer anIndex) const
143{
144 gp_XYZ tempXYZ = thePoles->Value(anIndex);
145 gp_Pnt Pole(tempXYZ);
146 return Pole;
147}
148
149 gp_Pnt IGESGeom_BSplineCurve::TransformedPole
150 (const Standard_Integer anIndex) const
151{
152 gp_XYZ tempXYZ = thePoles->Value(anIndex);
153 if (HasTransf()) Location().Transforms(tempXYZ);
154 gp_Pnt Pole(tempXYZ);
155 return Pole;
156}
157
158 Standard_Real IGESGeom_BSplineCurve::UMin () const
159{
160 return theUmin;
161}
162
163 Standard_Real IGESGeom_BSplineCurve::UMax () const
164{
165 return theUmax;
166}
167
168 gp_XYZ IGESGeom_BSplineCurve::Normal () const
169{
170 return theNorm;
171}