summaryrefslogtreecommitdiff
path: root/src/IGESGeom/IGESGeom_BSplineSurface.cxx
blob: c9f6a6f97470835d14fe8b13d71d08e625bc9a23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
//--------------------------------------------------------------------
//
//  File Name : IGESGeom_BSplineSurface.cxx
//  Date      :
//  Author    : CKY / Contract Toubro-Larsen
//  Copyright : MATRA-DATAVISION 1993
//
//--------------------------------------------------------------------

#include <IGESGeom_BSplineSurface.ixx>
#include <Standard_OutOfRange.hxx>
#include <gp_GTrsf.hxx>


    IGESGeom_BSplineSurface::IGESGeom_BSplineSurface ()    {  }


    void IGESGeom_BSplineSurface::Init
  (const Standard_Integer anIndexU, 
   const Standard_Integer anIndexV, const Standard_Integer aDegU,
   const Standard_Integer aDegV, const Standard_Boolean aCloseU,
   const Standard_Boolean aCloseV, const Standard_Boolean aPolynom,
   const Standard_Boolean aPeriodU, const Standard_Boolean aPeriodV,
   const Handle(TColStd_HArray1OfReal)& allKnotsU,
   const Handle(TColStd_HArray1OfReal)& allKnotsV,
   const Handle(TColStd_HArray2OfReal)& allWeights,
   const Handle(TColgp_HArray2OfXYZ)& allPoles,
   const Standard_Real aUmin, const Standard_Real aUmax,
   const Standard_Real aVmin, const Standard_Real aVmax)
{
  if (allWeights->RowLength() !=  allPoles->RowLength() || 
      allWeights->ColLength() !=  allPoles->ColLength())
    Standard_DimensionMismatch::Raise("IGESGeom_BSplineSurface : Init");
  if (allKnotsU->Lower() != -aDegU       || allKnotsV->Lower() != -aDegV     ||
      allKnotsU->Upper() != anIndexU+1   || allKnotsV->Upper() != anIndexV+1 ||
      allWeights->LowerRow() != 0        || allWeights->LowerCol() != 0 ||
      allPoles->LowerRow()   != 0        || allPoles->LowerCol()   != 0 ||
      allPoles->UpperRow()   != anIndexU || allPoles->UpperCol()   != anIndexV)
    Standard_DimensionMismatch::Raise("IGESGeom_BSplineSurface : Init");

  theIndexU    = anIndexU;
  theIndexV    = anIndexV;
  theDegreeU   = aDegU;
  theDegreeV   = aDegV;
  isClosedU    = aCloseU;
  isClosedV    = aCloseV;
  isPolynomial = aPolynom;
  isPeriodicU  = aPeriodU;
  isPeriodicV  = aPeriodV;
  theKnotsU    = allKnotsU; 
  theKnotsV    = allKnotsV; 
  theWeights   = allWeights;
  thePoles     = allPoles;
  theUmin      = aUmin;
  theUmax      = aUmax;
  theVmin      = aVmin;
  theVmax      = aVmax;
  InitTypeAndForm(128,FormNumber());
// FormNumber  precises the shape  0-9
}

    void  IGESGeom_BSplineSurface::SetFormNumber (const Standard_Integer form)
{
  if (form < 0 || form > 9) Standard_OutOfRange::Raise
    ("IGESGeom_BSplineSurface : SetFormNumber");
  InitTypeAndForm(128,form);
}

    Standard_Integer IGESGeom_BSplineSurface::UpperIndexU () const
{
  return theIndexU;
}

    Standard_Integer IGESGeom_BSplineSurface::UpperIndexV () const
{
  return theIndexV;
}

    Standard_Integer IGESGeom_BSplineSurface::DegreeU () const
{
  return theDegreeU;
}

    Standard_Integer IGESGeom_BSplineSurface::DegreeV () const
{
  return theDegreeV;
}

    Standard_Boolean IGESGeom_BSplineSurface::IsClosedU () const
{
  return isClosedU;
}

    Standard_Boolean IGESGeom_BSplineSurface::IsClosedV () const
{
  return isClosedV;
}

    Standard_Boolean IGESGeom_BSplineSurface::IsPolynomial
  (const Standard_Boolean flag) const
{
  if (flag) return isPolynomial;
  Standard_Integer i,j;
  Standard_Real w0 = theWeights->Value(0,0);
  for ( j = 0; j < theIndexV; j ++)
    for (i = 0; i < theIndexU; i ++)
      if (Abs(theWeights->Value(i,j) - w0) > 1.e-10) return Standard_False;
  return Standard_True;
}

    Standard_Boolean IGESGeom_BSplineSurface::IsPeriodicU () const
{
  return isPeriodicU;
}

    Standard_Boolean IGESGeom_BSplineSurface::IsPeriodicV () const
{
  return isPeriodicV;
}

    Standard_Integer IGESGeom_BSplineSurface::NbKnotsU () const
{
  return theKnotsU->Length();
}

    Standard_Integer IGESGeom_BSplineSurface::NbKnotsV () const
{
  return theKnotsV->Length();
}

    Standard_Real IGESGeom_BSplineSurface::KnotU
  (const Standard_Integer anIndex) const
{
  return theKnotsU->Value(anIndex);
}

    Standard_Real IGESGeom_BSplineSurface::KnotV
  (const Standard_Integer anIndex) const
{
  return theKnotsV->Value(anIndex);
}

    Standard_Integer IGESGeom_BSplineSurface::NbPolesU () const
{
  return theIndexU+1;
}

    Standard_Integer IGESGeom_BSplineSurface::NbPolesV () const
{
  return theIndexV+1;
}

    Standard_Real IGESGeom_BSplineSurface::Weight
  (const Standard_Integer anIndex1, const Standard_Integer anIndex2) const 
{
  return theWeights->Value(anIndex1, anIndex2);
}

    gp_Pnt IGESGeom_BSplineSurface::Pole
  (const Standard_Integer anIndex1, const Standard_Integer anIndex2) const
{
  gp_XYZ tempXYZ = thePoles->Value(anIndex1,anIndex2);
  // Reversal of the order of indices since the poles are
  // stored in the array like that. See ReadOwnParams()
  gp_Pnt Pole(tempXYZ);
  return Pole;
}

    gp_Pnt IGESGeom_BSplineSurface::TransformedPole
  (const Standard_Integer anIndex1, const Standard_Integer anIndex2) const
{
  gp_XYZ tempXYZ = thePoles->Value(anIndex1, anIndex2);
  // Reversal of the order of indices since the poles are
  // stored in the array like that. See ReadOwnParams()
  if (HasTransf()) Location().Transforms(tempXYZ);
  gp_Pnt Pole(tempXYZ);
  return Pole;
}

    Standard_Real IGESGeom_BSplineSurface::UMin ()  const
{
  return theUmin;
}

    Standard_Real IGESGeom_BSplineSurface::UMax ()  const
{
  return theUmax;
}

    Standard_Real IGESGeom_BSplineSurface::VMin ()  const
{
  return theVmin;
}

    Standard_Real IGESGeom_BSplineSurface::VMax ()  const
{
  return theVmax;
}