Line
Link Here
|
|
echo >&2 "$0: script expects -patch|-unpatch as argument" |
|
echo >&2 "$0: script expects -patch|-unpatch as argument" |
1 |
exit 1 |
1 |
exit 1 |
2 |
-patch) patch -f -p0 < $0;; |
2 |
-patch) patch -f -p0 < $0;; |
3 |
-unpatch) patch -f -R -p0 < $0;; |
3 |
-unpatch) patch -f -R -p0 < $0;; |
4 |
*) |
4 |
*) |
5 |
echo >&2 "$0: script expects -patch|-unpatch as argument" |
5 |
echo >&2 "$0: script expects -patch|-unpatch as argument" |
6 |
exit 1 |
6 |
exit 1 |
7 |
-- image/image.cpp.old |
7 |
++ image/image.cpp |
Lines 55-63
Link Here
|
55 |
void MatrixImage<T>::drawLine(int i1, int j1, int i2, int j2, T color){ |
55 |
void MatrixImage<T>::drawLine(int i1, int j1, int i2, int j2, T color){ |
56 |
int i,j ; |
56 |
int i,j ; |
57 |
double mx,b ; |
57 |
double mx,b ; |
58 |
if(i1<0 || j1<0 || i1>rows() || j1>=cols() ){ |
58 |
if(i1<0 || j1<0 || i1>this->rows() || j1>=this->cols() ){ |
59 |
#ifdef USE_EXCEPTION |
59 |
#ifdef USE_EXCEPTION |
60 |
throw OutOfBound2D(i1,j1,0,rows()-1,0,cols()-1) ; |
60 |
throw OutOfBound2D(i1,j1,0,this->rows()-1,0,this->cols()-1) ; |
61 |
#else |
61 |
#else |
62 |
Error error("MatrixImage<T>::drawLine") ; |
62 |
Error error("MatrixImage<T>::drawLine") ; |
63 |
error << "Error in drawing line\n Invalid index ("<< i1 << ", " << j1 << ") to ( " << i2 << ", " << j2 << ") \n" ; |
63 |
error << "Error in drawing line\n Invalid index ("<< i1 << ", " << j1 << ") to ( " << i2 << ", " << j2 << ") \n" ; |
Lines 65-73
Link Here
|
65 |
#endif |
65 |
#endif |
66 |
return ; |
66 |
return ; |
67 |
} |
67 |
} |
68 |
if(i2 <0 || j2<0 || i2>rows() || j2>=cols() ){ |
68 |
if(i2 <0 || j2<0 || i2>this->rows() || j2>=this->cols() ){ |
69 |
#ifdef USE_EXCEPTION |
69 |
#ifdef USE_EXCEPTION |
70 |
throw OutOfBound2D(i2,j2,0,rows()-1,0,cols()-1) ; |
70 |
throw OutOfBound2D(i2,j2,0,this->rows()-1,0,this->cols()-1) ; |
71 |
#else |
71 |
#else |
72 |
Error error("MatrixImage<T>::drawLine") ; |
72 |
Error error("MatrixImage<T>::drawLine") ; |
73 |
error << "Error in drawing line\n Invalid index ("<< i1 << ", " << j1 << ") to ( " << i2 << ", " << j2 << ") \n" ; |
73 |
error << "Error in drawing line\n Invalid index ("<< i1 << ", " << j1 << ") to ( " << i2 << ", " << j2 << ") \n" ; |
Lines 79-85
Link Here
|
79 |
// check if line is vertical |
79 |
// check if line is vertical |
80 |
if(j1==j2){ |
80 |
if(j1==j2){ |
81 |
for(i=minimum(i1,i2);i<=maximum(i1,i2);i++) |
81 |
for(i=minimum(i1,i2);i<=maximum(i1,i2);i++) |
82 |
operator()(i,j1) = color ; |
82 |
this->operator()(i,j1) = color ; |
83 |
return ; |
83 |
return ; |
84 |
} |
84 |
} |
85 |
mx = (double)(i1-i2)/(double)(j1-j2) ; |
85 |
mx = (double)(i1-i2)/(double)(j1-j2) ; |
Lines 88-100
Link Here
|
88 |
if(i1>i2){ |
88 |
if(i1>i2){ |
89 |
for(i=i1;i>=i2;i--){ |
89 |
for(i=i1;i>=i2;i--){ |
90 |
j = int(((double)i-b)/mx) ; |
90 |
j = int(((double)i-b)/mx) ; |
91 |
operator()(i,j) = color ; |
91 |
this->operator()(i,j) = color ; |
92 |
} |
92 |
} |
93 |
} |
93 |
} |
94 |
else{ |
94 |
else{ |
95 |
for(i=i1;i<=i2;i++){ |
95 |
for(i=i1;i<=i2;i++){ |
96 |
j = (int)((i-b)/mx) ; |
96 |
j = (int)((i-b)/mx) ; |
97 |
operator()(i,j) = color ; |
97 |
this->operator()(i,j) = color ; |
98 |
} |
98 |
} |
99 |
} |
99 |
} |
100 |
} |
100 |
} |
Lines 102-114
Link Here
|
102 |
if(j1>j2){ |
102 |
if(j1>j2){ |
103 |
for(j=j1;j>=j2;j--){ |
103 |
for(j=j1;j>=j2;j--){ |
104 |
i = (int)(mx*j+b) ; |
104 |
i = (int)(mx*j+b) ; |
105 |
operator()(i,j) = color ; |
105 |
this->operator()(i,j) = color ; |
106 |
} |
106 |
} |
107 |
} |
107 |
} |
108 |
else{ |
108 |
else{ |
109 |
for(j=j1;j<=j2;j++){ |
109 |
for(j=j1;j<=j2;j++){ |
110 |
i = (int)(mx*j+b) ; |
110 |
i = (int)(mx*j+b) ; |
111 |
operator()(i,j) = color ; |
111 |
this->operator()(i,j) = color ; |
112 |
} |
112 |
} |
113 |
} |
113 |
} |
114 |
} |
114 |
} |
Lines 133-141
Link Here
|
133 |
void MatrixImage<T>::drawPoint(int i, int j, double r , T color){ |
133 |
void MatrixImage<T>::drawPoint(int i, int j, double r , T color){ |
134 |
for(int y=i-int(ceil(r)) ; y<i+int(ceil(r)) ; y++) |
134 |
for(int y=i-int(ceil(r)) ; y<i+int(ceil(r)) ; y++) |
135 |
for(int x = j-int(ceil(r)) ; x<j+int(ceil(r)) ; x++){ |
135 |
for(int x = j-int(ceil(r)) ; x<j+int(ceil(r)) ; x++){ |
136 |
if(y>=0 && y<rows() && x>=0 && x<cols()){ |
136 |
if(y>=0 && y<this->rows() && x>=0 && x<this->cols()){ |
137 |
if( ((y-i)*(y-i)+(x-j)*(x-j))<= r*r) |
137 |
if( ((y-i)*(y-i)+(x-j)*(x-j))<= r*r) |
138 |
operator()(y,x) = color ; |
138 |
this->operator()(y,x) = color ; |
139 |
} |
139 |
} |
140 |
} |
140 |
} |
141 |
} |
141 |
} |
Lines 153-166
Link Here
|
153 |
*/ |
153 |
*/ |
154 |
template <class T> |
154 |
template <class T> |
155 |
void MatrixImage<T>::store(Matrix<T>& a){ |
155 |
void MatrixImage<T>::store(Matrix<T>& a){ |
156 |
if(a.rows() != rows() || a.cols() != cols()) { |
156 |
if(a.rows() != this->rows() || a.cols() != this->cols()) { |
157 |
a.resize(rows(),cols()) ; |
157 |
a.resize(this->rows(),this->cols()) ; |
158 |
} |
158 |
} |
159 |
T *aptr, *bptr ; |
159 |
T *aptr, *bptr ; |
160 |
int size,i ; |
160 |
int size,i ; |
161 |
aptr = &a(0,0)-1 ; |
161 |
aptr = &a(0,0)-1 ; |
162 |
bptr = m-1 ; |
162 |
bptr = this->m-1 ; |
163 |
size = cols()*rows() ; |
163 |
size = this->cols()*this->rows() ; |
164 |
for(i=0;i<size;i++) |
164 |
for(i=0;i<size;i++) |
165 |
*(++aptr) = *(++bptr) ; |
165 |
*(++aptr) = *(++bptr) ; |
166 |
} |
166 |
} |
167 |
-- matrix/cvector.h.old |
167 |
++ matrix/cvector.h |
Lines 54-63
Link Here
|
54 |
CVector(const BasicArray<T>& v) : Vector<T>(v), index(0) {;} |
54 |
CVector(const BasicArray<T>& v) : Vector<T>(v), index(0) {;} |
55 |
virtual ~CVector() {} |
55 |
virtual ~CVector() {} |
56 |
|
56 |
|
57 |
T& operator[](const int i) { return x[i%sze]; } |
57 |
T& operator[](const int i) { return this->x[i%this->sze]; } |
58 |
T operator[](const int i) const { return x[i%sze]; } |
58 |
T operator[](const int i) const { return this->x[i%this->sze]; } |
59 |
|
59 |
|
60 |
void put(T v) { x[index] = v ; index = (index+1)%sze; } |
60 |
void put(T v) { this->x[index] = v ; index = (index+1)%this->sze; } |
61 |
|
61 |
|
62 |
protected: |
62 |
protected: |
63 |
int index ; |
63 |
int index ; |
64 |
-- matrix/list.h.old |
64 |
++ matrix/list.h |
Lines 56-62
Link Here
|
56 |
{ |
56 |
{ |
57 |
public: |
57 |
public: |
58 |
BasicList() ; |
58 |
BasicList() ; |
59 |
BasicList(BasicList<T>& a) ; |
59 |
BasicList(const BasicList<T>& a) ; |
60 |
~BasicList() { reset() ; } |
60 |
~BasicList() { reset() ; } |
61 |
|
61 |
|
62 |
|
62 |
|
Lines 125-131
Link Here
|
125 |
Modified by: |
125 |
Modified by: |
126 |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
126 |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
127 |
template <class T> |
127 |
template <class T> |
128 |
BasicList<T>::BasicList(BasicList<T>& a): BasicNode<T>() { |
128 |
BasicList<T>::BasicList(const BasicList<T>& a): BasicNode<T>() { |
129 |
first_ = last_ = 0 ; |
129 |
first_ = last_ = 0 ; |
130 |
current = first_ ; |
130 |
current = first_ ; |
131 |
*this = a ; |
131 |
*this = a ; |
132 |
-- matrix/matrix.cpp.old |
132 |
++ matrix/matrix.cpp |
Lines 54-72
Link Here
|
54 |
if ( this == &a ) |
54 |
if ( this == &a ) |
55 |
return *this; |
55 |
return *this; |
56 |
|
56 |
|
57 |
if ( a.rows() != rows() || a.cols() != cols() ){ |
57 |
if ( a.rows() != this->rows() || a.cols() != this->cols() ){ |
58 |
resize(a.rows(),a.cols()) ; |
58 |
resize(a.rows(),a.cols()) ; |
59 |
} |
59 |
} |
60 |
|
60 |
|
61 |
int sze = rows()*cols() ; |
61 |
int sze = this->rows()*this->cols() ; |
62 |
T *ptr, *aptr ; |
62 |
T *ptr, *aptr ; |
63 |
ptr = m-1 ; |
63 |
ptr = this->m-1 ; |
64 |
aptr = a.m-1 ; |
64 |
aptr = a.m-1 ; |
65 |
|
65 |
|
66 |
for (i = sze; i > 0; --i) |
66 |
for (i = sze; i > 0; --i) |
67 |
*(++ptr) = *(++aptr) ; |
67 |
*(++ptr) = *(++aptr) ; |
68 |
|
68 |
|
69 |
by_columns = a.by_columns; |
69 |
this->by_columns = a.by_columns; |
70 |
|
70 |
|
71 |
return *this; |
71 |
return *this; |
72 |
} |
72 |
} |
Lines 100-109
Link Here
|
100 |
{ |
100 |
{ |
101 |
int rwz,coz,i,j; |
101 |
int rwz,coz,i,j; |
102 |
|
102 |
|
103 |
if ( rows() % a.rows() != 0 || cols() % a.cols() != 0 || rows() < a.rows() || cols() < a.cols() ) |
103 |
if ( this->rows() % a.rows() != 0 || this->cols() % a.cols() != 0 || this->rows() < a.rows() || this->cols() < a.cols() ) |
104 |
{ |
104 |
{ |
105 |
#ifdef USE_EXCEPTION |
105 |
#ifdef USE_EXCEPTION |
106 |
throw WrongSize2D(rows(),cols(),a.rows(),a.cols()) ; |
106 |
throw WrongSize2D(this->rows(),this->cols(),a.rows(),a.cols()) ; |
107 |
#else |
107 |
#else |
108 |
Error error("Matrix<T>::submatrix"); |
108 |
Error error("Matrix<T>::submatrix"); |
109 |
error << "Matrix and submatrix incommensurate" ; |
109 |
error << "Matrix and submatrix incommensurate" ; |
Lines 111-120
Link Here
|
111 |
#endif |
111 |
#endif |
112 |
} |
112 |
} |
113 |
|
113 |
|
114 |
if ( sr >= rows()/a.rows() || sr < 0 || sc >= cols()/a.cols() || sc < 0 ) |
114 |
if ( sr >= this->rows()/a.rows() || sr < 0 || sc >= this->cols()/a.cols() || sc < 0 ) |
115 |
{ |
115 |
{ |
116 |
#ifdef USE_EXCEPTION |
116 |
#ifdef USE_EXCEPTION |
117 |
throw OutOfBound2D(sr,sc,0,rows()/a.rows()-1,0,cols()/a.cols()-1) ; |
117 |
throw OutOfBound2D(sr,sc,0,this->rows()/a.rows()-1,0,this->cols()/a.cols()-1) ; |
118 |
#else |
118 |
#else |
119 |
Error error("Matrix<T>::submatrix"); |
119 |
Error error("Matrix<T>::submatrix"); |
120 |
error << "Submatrix location out of bounds.\nrowblock " << sr << ", " << rows()/a.rows() << " colblock " << sc << ", " << a.cols() << endl ; |
120 |
error << "Submatrix location out of bounds.\nrowblock " << sr << ", " << rows()/a.rows() << " colblock " << sc << ", " << a.cols() << endl ; |
Lines 133-139
Link Here
|
133 |
aptr = a.m - 1; |
133 |
aptr = a.m - 1; |
134 |
for ( i = a.rows()-1; i >= 0; --i ) |
134 |
for ( i = a.rows()-1; i >= 0; --i ) |
135 |
{ |
135 |
{ |
136 |
ptr = &m[(i+rwz)*cols()+coz]-1 ; |
136 |
ptr = &this->m[(i+rwz)*this->cols()+coz]-1 ; |
137 |
for ( j = a.cols(); j > 0; --j) |
137 |
for ( j = a.cols(); j > 0; --j) |
138 |
*(++ptr) = *(++aptr) ; |
138 |
*(++ptr) = *(++aptr) ; |
139 |
} |
139 |
} |
Lines 159-165
Link Here
|
159 |
// Assign matrix a to this matrix at (i,j) |
159 |
// Assign matrix a to this matrix at (i,j) |
160 |
int i, j; |
160 |
int i, j; |
161 |
|
161 |
|
162 |
if ( (rw + a.rows()) > rows() || ( cl + a.cols()) > cols()) { |
162 |
if ( (rw + a.rows()) > this->rows() || ( cl + a.cols()) > this->cols()) { |
163 |
#ifdef USE_EXCEPTION |
163 |
#ifdef USE_EXCEPTION |
164 |
throw MatrixErr(); |
164 |
throw MatrixErr(); |
165 |
#else |
165 |
#else |
Lines 177-183
Link Here
|
177 |
T *pptr,*aptr ; |
177 |
T *pptr,*aptr ; |
178 |
aptr = a.m-1 ; |
178 |
aptr = a.m-1 ; |
179 |
for ( i = 0; i<a.rows(); ++i) { |
179 |
for ( i = 0; i<a.rows(); ++i) { |
180 |
pptr = &m[(i+rw)*cols()+cl]-1 ; |
180 |
pptr = &this->m[(i+rw)*this->cols()+cl]-1 ; |
181 |
for ( j = 0; j < a.cols(); ++j) |
181 |
for ( j = 0; j < a.cols(); ++j) |
182 |
*(++pptr) = *(++aptr); |
182 |
*(++pptr) = *(++aptr); |
183 |
} |
183 |
} |
Lines 208-214
Link Here
|
208 |
Matrix<T> Matrix<T>::get(int rw, int cl, int nr, int nc) const |
208 |
Matrix<T> Matrix<T>::get(int rw, int cl, int nr, int nc) const |
209 |
{ |
209 |
{ |
210 |
Matrix<T> getmat(nr,nc) ; |
210 |
Matrix<T> getmat(nr,nc) ; |
211 |
if ( (rw+nr) > rows() || (cl+nc) > cols()) { |
211 |
if ( (rw+nr) > this->rows() || (cl+nc) > this->cols()) { |
212 |
#ifdef USE_EXCEPTION |
212 |
#ifdef USE_EXCEPTION |
213 |
throw MatrixErr(); |
213 |
throw MatrixErr(); |
214 |
#else |
214 |
#else |
Lines 228-234
Link Here
|
228 |
T *pptr,*aptr ; |
228 |
T *pptr,*aptr ; |
229 |
aptr = getmat.m-1; |
229 |
aptr = getmat.m-1; |
230 |
for (i = 0; i < nr; ++i) { |
230 |
for (i = 0; i < nr; ++i) { |
231 |
pptr = &m[(i+rw)*cols()+cl]-1 ; |
231 |
pptr = &this->m[(i+rw)*this->cols()+cl]-1 ; |
232 |
for ( j = 0; j < nc; ++j) |
232 |
for ( j = 0; j < nc; ++j) |
233 |
*(++aptr) = *(++pptr) ; |
233 |
*(++aptr) = *(++pptr) ; |
234 |
} |
234 |
} |
Lines 252-262
Link Here
|
252 |
double sum, maxsum; |
252 |
double sum, maxsum; |
253 |
int init=0 ; |
253 |
int init=0 ; |
254 |
T *pptr ; |
254 |
T *pptr ; |
255 |
pptr = m-1 ; |
255 |
pptr = this->m-1 ; |
256 |
maxsum = 0 ; // Silence the warning message |
256 |
maxsum = 0 ; // Silence the warning message |
257 |
for(i=0;i<rows();++i){ |
257 |
for(i=0;i<this->rows();++i){ |
258 |
sum = 0 ; |
258 |
sum = 0 ; |
259 |
for ( j = 0; j < cols(); ++j) |
259 |
for ( j = 0; j < this->cols(); ++j) |
260 |
sum += *(++pptr) ; |
260 |
sum += *(++pptr) ; |
261 |
if(init) |
261 |
if(init) |
262 |
maxsum = (maxsum>sum) ? maxsum : sum; |
262 |
maxsum = (maxsum>sum) ? maxsum : sum; |
Lines 285-296
Link Here
|
285 |
{ |
285 |
{ |
286 |
int i, iend; |
286 |
int i, iend; |
287 |
|
287 |
|
288 |
iend = rows(); |
288 |
iend = this->rows(); |
289 |
if ( iend > cols() ) |
289 |
if ( iend > this->cols() ) |
290 |
iend = cols(); |
290 |
iend = this->cols(); |
291 |
|
291 |
|
292 |
for (i = iend-1; i >=0; --i) |
292 |
for (i = iend-1; i >=0; --i) |
293 |
elem(i,i) = a; |
293 |
this->elem(i,i) = a; |
294 |
|
294 |
|
295 |
} |
295 |
} |
296 |
|
296 |
|
Lines 308-317
Link Here
|
308 |
template <class T> |
308 |
template <class T> |
309 |
Vector<T> Matrix<T>::getDiag(){ |
309 |
Vector<T> Matrix<T>::getDiag(){ |
310 |
int i, iend; |
310 |
int i, iend; |
311 |
Vector<T> vec(minimum(rows(),cols())) ; |
311 |
Vector<T> vec(minimum(this->rows(),this->cols())) ; |
312 |
iend = minimum(rows(),cols()); |
312 |
iend = minimum(this->rows(),this->cols()); |
313 |
for (i = iend-1; i >=0; --i) |
313 |
for (i = iend-1; i >=0; --i) |
314 |
vec[i] = elem(i,i); |
314 |
vec[i] = this->elem(i,i); |
315 |
return vec ; |
315 |
return vec ; |
316 |
} |
316 |
} |
317 |
|
317 |
|
Lines 328-335
Link Here
|
328 |
Matrix<T>& Matrix<T>::operator+=(double a) |
328 |
Matrix<T>& Matrix<T>::operator+=(double a) |
329 |
{ |
329 |
{ |
330 |
T *p1 ; |
330 |
T *p1 ; |
331 |
p1 = m-1 ; |
331 |
p1 = this->m-1 ; |
332 |
const int size = rows()*cols() ; |
332 |
const int size = this->rows()*this->cols() ; |
333 |
for(int i=size; i>0; --i) |
333 |
for(int i=size; i>0; --i) |
334 |
*(++p1) += a ; |
334 |
*(++p1) += a ; |
335 |
return *this ; |
335 |
return *this ; |
Lines 348-355
Link Here
|
348 |
Matrix<T>& Matrix<T>::operator-=(double a) |
348 |
Matrix<T>& Matrix<T>::operator-=(double a) |
349 |
{ |
349 |
{ |
350 |
T *p1 ; |
350 |
T *p1 ; |
351 |
p1 = m-1 ; |
351 |
p1 = this->m-1 ; |
352 |
const int size = rows()*cols() ; |
352 |
const int size = this->rows()*this->cols() ; |
353 |
for(int i=size; i>0; --i) |
353 |
for(int i=size; i>0; --i) |
354 |
*(++p1) -= a ; |
354 |
*(++p1) -= a ; |
355 |
return *this ; |
355 |
return *this ; |
Lines 368-375
Link Here
|
368 |
Matrix<T>& Matrix<T>::operator*=(double a) |
368 |
Matrix<T>& Matrix<T>::operator*=(double a) |
369 |
{ |
369 |
{ |
370 |
T *p1 ; |
370 |
T *p1 ; |
371 |
p1 = m-1 ; |
371 |
p1 = this->m-1 ; |
372 |
const int size = rows()*cols() ; |
372 |
const int size = this->rows()*this->cols() ; |
373 |
for(int i=size; i>0; --i) |
373 |
for(int i=size; i>0; --i) |
374 |
*(++p1) *= a ; |
374 |
*(++p1) *= a ; |
375 |
return *this ; |
375 |
return *this ; |
Lines 388-395
Link Here
|
388 |
Matrix<T>& Matrix<T>::operator/=(double a) |
388 |
Matrix<T>& Matrix<T>::operator/=(double a) |
389 |
{ |
389 |
{ |
390 |
T *p1 ; |
390 |
T *p1 ; |
391 |
p1 = m-1 ; |
391 |
p1 = this->m-1 ; |
392 |
const int size = rows()*cols() ; |
392 |
const int size = this->rows()*this->cols() ; |
393 |
for(int i=size; i>0; --i) |
393 |
for(int i=size; i>0; --i) |
394 |
*(++p1) /= a ; |
394 |
*(++p1) /= a ; |
395 |
return *this ; |
395 |
return *this ; |
Lines 408-417
Link Here
|
408 |
template <class T> |
408 |
template <class T> |
409 |
Matrix<T>& Matrix<T>::operator+=(const Matrix<T> &a) |
409 |
Matrix<T>& Matrix<T>::operator+=(const Matrix<T> &a) |
410 |
{ |
410 |
{ |
411 |
if ( a.rows() != rows() || a.cols() != cols() ) |
411 |
if ( a.rows() != this->rows() || a.cols() != this->cols() ) |
412 |
{ |
412 |
{ |
413 |
#ifdef USE_EXCEPTION |
413 |
#ifdef USE_EXCEPTION |
414 |
throw WrongSize2D(rows(),cols(),a.rows(),a.cols()); |
414 |
throw WrongSize2D(this->rows(),this->cols(),a.rows(),a.cols()); |
415 |
#else |
415 |
#else |
416 |
Error error("Matrix<T>::operator+=") ; |
416 |
Error error("Matrix<T>::operator+=") ; |
417 |
if ( rows() != a.rows() ) |
417 |
if ( rows() != a.rows() ) |
Lines 425-432
Link Here
|
425 |
int i, sze ; |
425 |
int i, sze ; |
426 |
T *aptr,*sptr ; |
426 |
T *aptr,*sptr ; |
427 |
aptr = a.m - 1 ; |
427 |
aptr = a.m - 1 ; |
428 |
sptr = m - 1 ; |
428 |
sptr = this->m - 1 ; |
429 |
sze = rows()*cols() ; |
429 |
sze = this->rows()*this->cols() ; |
430 |
for (i = sze; i > 0; --i){ |
430 |
for (i = sze; i > 0; --i){ |
431 |
*(++sptr) += *(++aptr) ; |
431 |
*(++sptr) += *(++aptr) ; |
432 |
} |
432 |
} |
Lines 468-477
Link Here
|
468 |
template <class T> |
468 |
template <class T> |
469 |
Matrix<T>& Matrix<T>::operator-=(const Matrix<T> &a) |
469 |
Matrix<T>& Matrix<T>::operator-=(const Matrix<T> &a) |
470 |
{ |
470 |
{ |
471 |
if ( a.rows() != rows() || a.cols() != cols() ) |
471 |
if ( a.rows() != this->rows() || a.cols() != this->cols() ) |
472 |
{ |
472 |
{ |
473 |
#ifdef USE_EXCEPTION |
473 |
#ifdef USE_EXCEPTION |
474 |
throw WrongSize2D(rows(),cols(),a.rows(),a.cols()); |
474 |
throw WrongSize2D(this->rows(),this->cols(),a.rows(),a.cols()); |
475 |
#else |
475 |
#else |
476 |
Error error("Matrix<T>::operator-=") ; |
476 |
Error error("Matrix<T>::operator-=") ; |
477 |
if ( rows() != a.rows() ) |
477 |
if ( rows() != a.rows() ) |
Lines 485-492
Link Here
|
485 |
int i, size; |
485 |
int i, size; |
486 |
T *aptr,*sptr ; |
486 |
T *aptr,*sptr ; |
487 |
aptr = a.m - 1 ; |
487 |
aptr = a.m - 1 ; |
488 |
sptr = m - 1 ; |
488 |
sptr = this->m - 1 ; |
489 |
size = rows()*cols() ; |
489 |
size = this->rows()*this->cols() ; |
490 |
for (i = size; i > 0; --i){ |
490 |
for (i = size; i > 0; --i){ |
491 |
*(++sptr) -= *(++aptr) ; |
491 |
*(++sptr) -= *(++aptr) ; |
492 |
} |
492 |
} |
Lines 742-755
Link Here
|
742 |
template <class T> |
742 |
template <class T> |
743 |
T Matrix<T>::trace() const |
743 |
T Matrix<T>::trace() const |
744 |
{ |
744 |
{ |
745 |
int size = rows(); |
745 |
int size = this->rows(); |
746 |
T sum = (T)0; |
746 |
T sum = (T)0; |
747 |
|
747 |
|
748 |
if ( size > cols() ) |
748 |
if ( size > this->cols() ) |
749 |
size = cols(); |
749 |
size = this->cols(); |
750 |
|
750 |
|
751 |
for (int d = 0; d < size; ++d) |
751 |
for (int d = 0; d < size; ++d) |
752 |
sum += elem(d,d) ; |
752 |
sum += this->elem(d,d) ; |
753 |
|
753 |
|
754 |
return sum; |
754 |
return sum; |
755 |
} |
755 |
} |
Lines 770-781
Link Here
|
770 |
template <class T> |
770 |
template <class T> |
771 |
Matrix<T> Matrix<T>::herm() const |
771 |
Matrix<T> Matrix<T>::herm() const |
772 |
{ |
772 |
{ |
773 |
int i, j, r = cols(), c = rows(); |
773 |
int i, j, r = this->cols(), c = this->rows(); |
774 |
Matrix<T> adj(r,c); |
774 |
Matrix<T> adj(r,c); |
775 |
|
775 |
|
776 |
for (i = 0; i < r; ++i) |
776 |
for (i = 0; i < r; ++i) |
777 |
for (j = 0; j < c; ++j) |
777 |
for (j = 0; j < c; ++j) |
778 |
adj.elem(i,j) = elem(j,i) ; |
778 |
adj.elem(i,j) = this->elem(j,i) ; |
779 |
|
779 |
|
780 |
return adj; |
780 |
return adj; |
781 |
|
781 |
|
Lines 794-804
Link Here
|
794 |
template <class T> |
794 |
template <class T> |
795 |
Matrix<T> Matrix<T>::flop() const |
795 |
Matrix<T> Matrix<T>::flop() const |
796 |
{ |
796 |
{ |
797 |
Matrix<T> f(rows(),cols()) ; |
797 |
Matrix<T> f(this->rows(),this->cols()) ; |
798 |
for(int i=rows()-1;i>=0;--i) |
798 |
for(int i=this->rows()-1;i>=0;--i) |
799 |
for(int j=cols()-1;j>=0;--j) |
799 |
for(int j=this->cols()-1;j>=0;--j) |
800 |
{ |
800 |
{ |
801 |
f(i,j) = elem(i,cols()-j-1); |
801 |
f(i,j) = elem(i,this->cols()-j-1); |
802 |
} |
802 |
} |
803 |
return f; |
803 |
return f; |
804 |
} |
804 |
} |
Lines 817-829
Link Here
|
817 |
{ |
817 |
{ |
818 |
// same as hermitian for real Matrix<T> |
818 |
// same as hermitian for real Matrix<T> |
819 |
int i, j; |
819 |
int i, j; |
820 |
const int& r = cols(); |
820 |
const int& r = this->cols(); |
821 |
const int& c = rows(); |
821 |
const int& c = this->rows(); |
822 |
Matrix<T> adj(r,c); |
822 |
Matrix<T> adj(r,c); |
823 |
|
823 |
|
824 |
for (i = r-1; i >=0; --i) |
824 |
for (i = r-1; i >=0; --i) |
825 |
for (j = c-1; j >=0; --j) |
825 |
for (j = c-1; j >=0; --j) |
826 |
adj.elem(i,j) = elem(j,i) ; |
826 |
adj.elem(i,j) = this->elem(j,i) ; |
827 |
|
827 |
|
828 |
|
828 |
|
829 |
return adj; |
829 |
return adj; |
Lines 844-850
Link Here
|
844 |
int Matrix<T>::read(char* filename) { |
844 |
int Matrix<T>::read(char* filename) { |
845 |
ifstream fin(filename) ; |
845 |
ifstream fin(filename) ; |
846 |
if(!fin) { |
846 |
if(!fin) { |
847 |
resize(1,1) ; |
847 |
this->resize(1,1) ; |
848 |
return 0 ; |
848 |
return 0 ; |
849 |
} |
849 |
} |
850 |
int r,c ; |
850 |
int r,c ; |
Lines 855-862
Link Here
|
855 |
if(r) return 0 ; |
855 |
if(r) return 0 ; |
856 |
if(!fin.read((char*)&r,sizeof(int))) return 0 ; |
856 |
if(!fin.read((char*)&r,sizeof(int))) return 0 ; |
857 |
if(!fin.read((char*)&c,sizeof(int))) return 0 ; |
857 |
if(!fin.read((char*)&c,sizeof(int))) return 0 ; |
858 |
resize(r,c) ; |
858 |
this->resize(r,c) ; |
859 |
if(!fin.read((char*)m,sizeof(T)*r*c)) return 0 ; |
859 |
if(!fin.read((char*)this->m,sizeof(T)*r*c)) return 0 ; |
860 |
|
860 |
|
861 |
delete []type ; |
861 |
delete []type ; |
862 |
return 1 ; |
862 |
return 1 ; |
Lines 877-887
Link Here
|
877 |
int Matrix<T>::read(char* filename,int r, int c) { |
877 |
int Matrix<T>::read(char* filename,int r, int c) { |
878 |
ifstream fin(filename) ; |
878 |
ifstream fin(filename) ; |
879 |
if(!fin) { |
879 |
if(!fin) { |
880 |
resize(1,1) ; |
880 |
this->resize(1,1) ; |
881 |
return 0 ; |
881 |
return 0 ; |
882 |
} |
882 |
} |
883 |
resize(r,c) ; |
883 |
this->resize(r,c) ; |
884 |
if(!fin.read((char*)m,sizeof(T)*r*c)) return 0 ; |
884 |
if(!fin.read((char*)this->m,sizeof(T)*r*c)) return 0 ; |
885 |
|
885 |
|
886 |
return 1 ; |
886 |
return 1 ; |
887 |
} |
887 |
} |
Lines 904-914
Link Here
|
904 |
if(!fout) |
904 |
if(!fout) |
905 |
return 0 ; |
905 |
return 0 ; |
906 |
int r,c ; |
906 |
int r,c ; |
907 |
r = rows() ; c = cols() ; |
907 |
r = this->rows() ; c = this->cols() ; |
908 |
if(!fout.write((char*)&"matrix",sizeof(char)*6)) return 0 ; |
908 |
if(!fout.write((char*)&"matrix",sizeof(char)*6)) return 0 ; |
909 |
if(!fout.write((char*)&r,sizeof(int))) return 0 ; |
909 |
if(!fout.write((char*)&r,sizeof(int))) return 0 ; |
910 |
if(!fout.write((char*)&c,sizeof(int))) return 0 ; |
910 |
if(!fout.write((char*)&c,sizeof(int))) return 0 ; |
911 |
if(!fout.write((char*)m,sizeof(T)*r*c)) return 0 ; |
911 |
if(!fout.write((char*)this->m,sizeof(T)*r*c)) return 0 ; |
912 |
return 1; |
912 |
return 1; |
913 |
} |
913 |
} |
914 |
|
914 |
|
Lines 927-933
Link Here
|
927 |
ofstream fout(filename) ; |
927 |
ofstream fout(filename) ; |
928 |
if(!fout) |
928 |
if(!fout) |
929 |
return 0 ; |
929 |
return 0 ; |
930 |
if(!fout.write((char*)m,sizeof(T)*rows()*cols())) return 0 ; |
930 |
if(!fout.write((char*)this->m,sizeof(T)*this->rows()*this->cols())) return 0 ; |
931 |
return 1; |
931 |
return 1; |
932 |
} |
932 |
} |
933 |
|
933 |
|
934 |
-- matrix/vector.cpp.old |
934 |
++ matrix/vector.cpp |
Lines 51-66
Link Here
|
51 |
if(this==&b) |
51 |
if(this==&b) |
52 |
return *this ; |
52 |
return *this ; |
53 |
|
53 |
|
54 |
if ( n() != b.n()) |
54 |
if ( this->n() != b.n()) |
55 |
{ |
55 |
{ |
56 |
resize(b.n()) ; |
56 |
resize(b.n()) ; |
57 |
} |
57 |
} |
58 |
|
58 |
|
59 |
sze = b.n() ; |
59 |
this->sze = b.n() ; |
60 |
T *pa, *pb ; |
60 |
T *pa, *pb ; |
61 |
pa = x-1 ; |
61 |
pa = this->x-1 ; |
62 |
pb = b.x-1 ; |
62 |
pb = b.x-1 ; |
63 |
for(int i=n();i>0;--i){ |
63 |
for(int i=this->n();i>0;--i){ |
64 |
*(++pa) = *(++pb) ; |
64 |
*(++pa) = *(++pb) ; |
65 |
} |
65 |
} |
66 |
return *this; |
66 |
return *this; |
Lines 79-91
Link Here
|
79 |
template <class T> |
79 |
template <class T> |
80 |
Vector<T>& Vector<T>::operator=(const BasicArray<T> &b) |
80 |
Vector<T>& Vector<T>::operator=(const BasicArray<T> &b) |
81 |
{ |
81 |
{ |
82 |
if ( size() != b.size()) |
82 |
if ( this->size() != b.size()) |
83 |
{ |
83 |
{ |
84 |
resize(b.size()) ; |
84 |
resize(b.size()) ; |
85 |
} |
85 |
} |
86 |
T *ptr ; |
86 |
T *ptr ; |
87 |
ptr = x - 1 ; |
87 |
ptr = this->x - 1 ; |
88 |
for(int i=size()-1;i>=0;--i) |
88 |
for(int i=this->size()-1;i>=0;--i) |
89 |
*(++ptr) = b[i] ; |
89 |
*(++ptr) = b[i] ; |
90 |
|
90 |
|
91 |
return *this; |
91 |
return *this; |
Lines 105-113
Link Here
|
105 |
template <class T> |
105 |
template <class T> |
106 |
T Vector<T>::operator=(const T d) |
106 |
T Vector<T>::operator=(const T d) |
107 |
{ |
107 |
{ |
108 |
const int sz = size(); |
108 |
const int sz = this->size(); |
109 |
T *ptr ; |
109 |
T *ptr ; |
110 |
ptr = x-1 ; |
110 |
ptr = this->x-1 ; |
111 |
for (int i = sz; i > 0; --i) |
111 |
for (int i = sz; i > 0; --i) |
112 |
*(++ptr) = d ; |
112 |
*(++ptr) = d ; |
113 |
|
113 |
|
Lines 130-148
Link Here
|
130 |
template <class T> |
130 |
template <class T> |
131 |
Vector<T>& Vector<T>::operator+=(const Vector<T> &a) |
131 |
Vector<T>& Vector<T>::operator+=(const Vector<T> &a) |
132 |
{ |
132 |
{ |
133 |
if ( a.size() != size()) |
133 |
if ( a.size() != this->size()) |
134 |
{ |
134 |
{ |
135 |
#ifdef USE_EXCEPTION |
135 |
#ifdef USE_EXCEPTION |
136 |
throw WrongSize(size(),a.size()) ; |
136 |
throw WrongSize(this->size(),a.size()) ; |
137 |
#else |
137 |
#else |
138 |
Error error("Vector<T>::operator+=(Vector<T>&)"); |
138 |
Error error("Vector<T>::operator+=(Vector<T>&)"); |
139 |
error << "Vector<T> a += Vector<T> b different sizes, a = " << size() << ", b = " << a.size() ; |
139 |
error << "Vector<T> a += Vector<T> b different sizes, a = " << size() << ", b = " << a.size() ; |
140 |
error.fatal() ; |
140 |
error.fatal() ; |
141 |
#endif |
141 |
#endif |
142 |
} |
142 |
} |
143 |
const int sz = size(); |
143 |
const int sz = this->size(); |
144 |
T *ptr,*aptr ; |
144 |
T *ptr,*aptr ; |
145 |
ptr = x-1 ; |
145 |
ptr = this->x-1 ; |
146 |
aptr = a.x-1 ; |
146 |
aptr = a.x-1 ; |
147 |
for (int i = sz; i >0; --i) |
147 |
for (int i = sz; i >0; --i) |
148 |
*(++ptr) += *(++aptr) ; |
148 |
*(++ptr) += *(++aptr) ; |
Lines 165-174
Link Here
|
165 |
template <class T> |
165 |
template <class T> |
166 |
Vector<T>& Vector<T>::operator-=(const Vector<T> &a) |
166 |
Vector<T>& Vector<T>::operator-=(const Vector<T> &a) |
167 |
{ |
167 |
{ |
168 |
if ( a.size() != size()) |
168 |
if ( a.size() != this->size()) |
169 |
{ |
169 |
{ |
170 |
#ifdef USE_EXCEPTION |
170 |
#ifdef USE_EXCEPTION |
171 |
throw WrongSize(size(),a.size()) ; |
171 |
throw WrongSize(this->size(),a.size()) ; |
172 |
#else |
172 |
#else |
173 |
Error error("Vector<T>::operator-=(Vector<T>&)"); |
173 |
Error error("Vector<T>::operator-=(Vector<T>&)"); |
174 |
error << "Vector<T> a -= Vector<T> b different sizes, a = " << size() << ", b = " << a.size() ; |
174 |
error << "Vector<T> a -= Vector<T> b different sizes, a = " << size() << ", b = " << a.size() ; |
Lines 176-184
Link Here
|
176 |
#endif |
176 |
#endif |
177 |
} |
177 |
} |
178 |
|
178 |
|
179 |
const int sz = size(); |
179 |
const int sz = this->size(); |
180 |
T *ptr,*aptr ; |
180 |
T *ptr,*aptr ; |
181 |
ptr = x-1 ; |
181 |
ptr = this->x-1 ; |
182 |
aptr = a.x-1 ; |
182 |
aptr = a.x-1 ; |
183 |
for (int i = sz; i > 0; --i) |
183 |
for (int i = sz; i > 0; --i) |
184 |
*(++ptr) -= *(++aptr) ; |
184 |
*(++ptr) -= *(++aptr) ; |
Lines 391-397
Link Here
|
391 |
} |
391 |
} |
392 |
|
392 |
|
393 |
T *aptr,*bptr ; |
393 |
T *aptr,*bptr ; |
394 |
aptr = &x[i]-1 ; |
394 |
aptr = &this->x[i]-1 ; |
395 |
bptr = b.x-1 ; |
395 |
bptr = b.x-1 ; |
396 |
for ( int j = b.rows(); j > 0; --j) |
396 |
for ( int j = b.rows(); j > 0; --j) |
397 |
*(++aptr) = *(++bptr) ; |
397 |
*(++aptr) = *(++bptr) ; |
Lines 429-435
Link Here
|
429 |
|
429 |
|
430 |
Vector<T> subvec(l) ; |
430 |
Vector<T> subvec(l) ; |
431 |
T *aptr, *bptr ; |
431 |
T *aptr, *bptr ; |
432 |
aptr = &x[i] - 1 ; |
432 |
aptr = &this->x[i] - 1 ; |
433 |
bptr = subvec.x -1 ; |
433 |
bptr = subvec.x -1 ; |
434 |
for ( int j = l; j > 0; --j) |
434 |
for ( int j = l; j > 0; --j) |
435 |
*(++bptr) = *(++aptr) ; |
435 |
*(++bptr) = *(++aptr) ; |
Lines 449-460
Link Here
|
449 |
*/ |
449 |
*/ |
450 |
template <class T> |
450 |
template <class T> |
451 |
int Vector<T>::minIndex() const { |
451 |
int Vector<T>::minIndex() const { |
452 |
T min = x[0] ; |
452 |
T min = this->x[0] ; |
453 |
int index = 0 ; |
453 |
int index = 0 ; |
454 |
|
454 |
|
455 |
for(int i=1;i<n();i++){ |
455 |
for(int i=1;i<this->n();i++){ |
456 |
if(x[i]<=min){ |
456 |
if(this->x[i]<=min){ |
457 |
min = x[i] ; |
457 |
min = this->x[i] ; |
458 |
index = i ; |
458 |
index = i ; |
459 |
} |
459 |
} |
460 |
} |
460 |
} |
Lines 523-534
Link Here
|
523 |
T a ; |
523 |
T a ; |
524 |
T *v1,*v2 ; |
524 |
T *v1,*v2 ; |
525 |
|
525 |
|
526 |
ir = sze-1 ; |
526 |
ir = this->sze-1 ; |
527 |
l = 0 ; |
527 |
l = 0 ; |
528 |
|
528 |
|
529 |
while(1){ |
529 |
while(1){ |
530 |
if(ir-l<M){ // perform an insertion sort when the array is small enough |
530 |
if(ir-l<M){ // perform an insertion sort when the array is small enough |
531 |
v1 = &x[l] ; |
531 |
v1 = &this->x[l] ; |
532 |
for(j=l+1;j<=ir;++j){ |
532 |
for(j=l+1;j<=ir;++j){ |
533 |
a = *(++v1) ; |
533 |
a = *(++v1) ; |
534 |
v2 = v1 ; |
534 |
v2 = v1 ; |
Lines 547-577
Link Here
|
547 |
} |
547 |
} |
548 |
else{ |
548 |
else{ |
549 |
k=(l+ir) >> 1 ; |
549 |
k=(l+ir) >> 1 ; |
550 |
swap(x[k],x[l+1]) ; |
550 |
swap(this->x[k],this->x[l+1]) ; |
551 |
if(x[l+1] > x[ir]){ |
551 |
if(this->x[l+1] > this->x[ir]){ |
552 |
swap(x[l+1],x[ir]) ; |
552 |
swap(this->x[l+1],this->x[ir]) ; |
553 |
} |
553 |
} |
554 |
if(x[l]> x[ir]){ |
554 |
if(this->x[l]> this->x[ir]){ |
555 |
swap(x[l],x[ir]) ; |
555 |
swap(this->x[l],this->x[ir]) ; |
556 |
} |
556 |
} |
557 |
if(x[l+1] > x[l]){ |
557 |
if(this->x[l+1] > this->x[l]){ |
558 |
swap(x[l+1],x[l]) ; |
558 |
swap(this->x[l+1],this->x[l]) ; |
559 |
} |
559 |
} |
560 |
i=l+1 ; |
560 |
i=l+1 ; |
561 |
j=ir ; |
561 |
j=ir ; |
562 |
a=x[l] ; |
562 |
a=this->x[l] ; |
563 |
v1 = &x[i] ; |
563 |
v1 = &this->x[i] ; |
564 |
v2 = &x[j] ; |
564 |
v2 = &this->x[j] ; |
565 |
while(1){ |
565 |
while(1){ |
566 |
while(*v1 < a) { ++i ; ++v1 ; } |
566 |
while(*v1 < a) { ++i ; ++v1 ; } |
567 |
while(*v2 > a) { --j ; --v2 ; } |
567 |
while(*v2 > a) { --j ; --v2 ; } |
568 |
if(j<i) break ; |
568 |
if(j<i) break ; |
569 |
if(*v1 == *v2) // both are equal to a... |
569 |
if(*v1 == *v2) // both are equal to a... |
570 |
break ; |
570 |
break ; |
571 |
swap(x[i],x[j]) ; |
571 |
swap(this->x[i],this->x[j]) ; |
572 |
} |
572 |
} |
573 |
x[l] = x[j] ; |
573 |
this->x[l] = this->x[j] ; |
574 |
x[j] = a ; |
574 |
this->x[j] = a ; |
575 |
jstack += 2 ; |
575 |
jstack += 2 ; |
576 |
if(jstack>=Nstack){ |
576 |
if(jstack>=Nstack){ |
577 |
istack.resize(istack.n()+Nstack) ; // increase the vector size |
577 |
istack.resize(istack.n()+Nstack) ; // increase the vector size |
Lines 618-627
Link Here
|
618 |
int jstack=0; |
618 |
int jstack=0; |
619 |
T a ; |
619 |
T a ; |
620 |
|
620 |
|
621 |
ir = sze-1 ; |
621 |
ir = this->sze-1 ; |
622 |
l = 0 ; |
622 |
l = 0 ; |
623 |
|
623 |
|
624 |
index.resize(sze) ; |
624 |
index.resize(this->sze) ; |
625 |
for(i=0;i<index.n();++i) |
625 |
for(i=0;i<index.n();++i) |
626 |
index[i] = i ; |
626 |
index[i] = i ; |
627 |
|
627 |
|
Lines 629-637
Link Here
|
629 |
if(ir-l<M){ // perform an insertion sort when the array is small enough |
629 |
if(ir-l<M){ // perform an insertion sort when the array is small enough |
630 |
for(j=l+1;j<=ir;++j){ |
630 |
for(j=l+1;j<=ir;++j){ |
631 |
indext = index[j] ; |
631 |
indext = index[j] ; |
632 |
a = x[indext] ; |
632 |
a = this->x[indext] ; |
633 |
for(i=j-1;i>=0;--i){ |
633 |
for(i=j-1;i>=0;--i){ |
634 |
if(x[index[i]] <= a) break ; |
634 |
if(this->x[index[i]] <= a) break ; |
635 |
index[i+1] = index[i] ; |
635 |
index[i+1] = index[i] ; |
636 |
} |
636 |
} |
637 |
index[i+1] = indext ; |
637 |
index[i+1] = indext ; |
Lines 643-666
Link Here
|
643 |
else{ |
643 |
else{ |
644 |
k=(l+ir) >> 1 ; |
644 |
k=(l+ir) >> 1 ; |
645 |
swap(index[k],index[l+1]) ; |
645 |
swap(index[k],index[l+1]) ; |
646 |
if(x[index[l+1]] > x[index[ir]]){ |
646 |
if(this->x[index[l+1]] > this->x[index[ir]]){ |
647 |
swap(index[l+1],index[ir]) ; |
647 |
swap(index[l+1],index[ir]) ; |
648 |
} |
648 |
} |
649 |
if(x[index[l]]> x[index[ir]]){ |
649 |
if(this->x[index[l]]> this->x[index[ir]]){ |
650 |
swap(index[l],index[ir]) ; |
650 |
swap(index[l],index[ir]) ; |
651 |
} |
651 |
} |
652 |
if(x[index[l+1]] > x[index[l]]){ |
652 |
if(this->x[index[l+1]] > this->x[index[l]]){ |
653 |
swap(index[l+1],index[l]) ; |
653 |
swap(index[l+1],index[l]) ; |
654 |
} |
654 |
} |
655 |
i=l+1 ; |
655 |
i=l+1 ; |
656 |
j=ir ; |
656 |
j=ir ; |
657 |
indext = index[l] ; |
657 |
indext = index[l] ; |
658 |
a=x[indext] ; |
658 |
a=this->x[indext] ; |
659 |
while(1){ |
659 |
while(1){ |
660 |
while(x[index[i]] < a) { ++i ; } |
660 |
while(this->x[index[i]] < a) { ++i ; } |
661 |
while(x[index[j]] > a) { --j ; } |
661 |
while(this->x[index[j]] > a) { --j ; } |
662 |
if(j<i) break ; |
662 |
if(j<i) break ; |
663 |
if(x[index[i]] == x[index[j]]) |
663 |
if(this->x[index[i]] == this->x[index[j]]) |
664 |
break ; |
664 |
break ; |
665 |
swap(index[i],index[j]) ; |
665 |
swap(index[i],index[j]) ; |
666 |
} |
666 |
} |
667 |
-- matrix/vector.h.old |
667 |
++ matrix/vector.h |
Lines 69-75
Link Here
|
69 |
{ |
69 |
{ |
70 |
public: |
70 |
public: |
71 |
int rows() const //!< a reference to the size of the vector |
71 |
int rows() const //!< a reference to the size of the vector |
72 |
{ return sze ;} |
72 |
{ return this->sze ;} |
73 |
Vector() : BasicArray<T>(1) {} //!< Basic constructor |
73 |
Vector() : BasicArray<T>(1) {} //!< Basic constructor |
74 |
Vector(const int r) : BasicArray<T>(r) {} |
74 |
Vector(const int r) : BasicArray<T>(r) {} |
75 |
Vector(const Vector<T>& v) : BasicArray<T>(v) {} |
75 |
Vector(const Vector<T>& v) : BasicArray<T>(v) {} |
76 |
-- numerical/matrixMat.cpp.old |
76 |
++ numerical/matrixMat.cpp |
Lines 48-56
Link Here
|
48 |
template <class T> |
48 |
template <class T> |
49 |
LUMatrix<T>& LUMatrix<T>::operator=(const LUMatrix<T>& a){ |
49 |
LUMatrix<T>& LUMatrix<T>::operator=(const LUMatrix<T>& a){ |
50 |
resize(a.rows(),a.cols()) ; |
50 |
resize(a.rows(),a.cols()) ; |
51 |
for(int i=0;i<rows();++i) |
51 |
for(int i=0;i<this->rows();++i) |
52 |
for(int j=0;j<cols();++j) |
52 |
for(int j=0;j<this->cols();++j) |
53 |
elem(i,j) = a(i,j) ; |
53 |
this->elem(i,j) = a(i,j) ; |
54 |
pivot_ = a.pivot_ ; |
54 |
pivot_ = a.pivot_ ; |
55 |
return *this ; |
55 |
return *this ; |
56 |
} |
56 |
} |
Lines 90-96
Link Here
|
90 |
// lu = a; must do it by copying or LUFACT will be recursively called ! |
90 |
// lu = a; must do it by copying or LUFACT will be recursively called ! |
91 |
for(i=0;i<n;++i) |
91 |
for(i=0;i<n;++i) |
92 |
for(j=0;j<n;++j) |
92 |
for(j=0;j<n;++j) |
93 |
elem(i,j) = a(i,j) ; |
93 |
this->elem(i,j) = a(i,j) ; |
94 |
|
94 |
|
95 |
errval = 0; |
95 |
errval = 0; |
96 |
nm1 = n - 1; |
96 |
nm1 = n - 1; |
Lines 129-152
Link Here
|
129 |
} |
129 |
} |
130 |
pivot_[k] = l; |
130 |
pivot_[k] = l; |
131 |
|
131 |
|
132 |
if ( elem(l,k) != 0.0 ) |
132 |
if ( this->elem(l,k) != 0.0 ) |
133 |
{ // nonsingular pivot found |
133 |
{ // nonsingular pivot found |
134 |
if (l != k ){ // interchange needed |
134 |
if (l != k ){ // interchange needed |
135 |
for (i = k; i < n; i++) |
135 |
for (i = k; i < n; i++) |
136 |
{ |
136 |
{ |
137 |
t = elem(l,i) ; |
137 |
t = this->elem(l,i) ; |
138 |
elem(l,i) = elem(k,i) ; |
138 |
this->elem(l,i) = this->elem(k,i) ; |
139 |
elem(k,i) = t ; |
139 |
this->elem(k,i) = t ; |
140 |
} |
140 |
} |
141 |
sign = -sign ; |
141 |
sign = -sign ; |
142 |
} |
142 |
} |
143 |
q = elem(k,k); /* scale row */ |
143 |
q = this->elem(k,k); /* scale row */ |
144 |
for (i = kp1; i < n; i++) |
144 |
for (i = kp1; i < n; i++) |
145 |
{ |
145 |
{ |
146 |
t = - elem(i,k)/q; |
146 |
t = - this->elem(i,k)/q; |
147 |
elem(i,k) = t; |
147 |
this->elem(i,k) = t; |
148 |
for (j = kp1; j < n; j++) |
148 |
for (j = kp1; j < n; j++) |
149 |
elem(i,j) += t * elem(k,j); |
149 |
this->elem(i,j) += t * this->elem(k,j); |
150 |
} |
150 |
} |
151 |
} |
151 |
} |
152 |
else /* pivot singular */ |
152 |
else /* pivot singular */ |
Lines 156-162
Link Here
|
156 |
} |
156 |
} |
157 |
|
157 |
|
158 |
pivot_[nm1] = nm1; |
158 |
pivot_[nm1] = nm1; |
159 |
if (elem(nm1,nm1) == 0.0) |
159 |
if (this->elem(nm1,nm1) == 0.0) |
160 |
errval = nm1; |
160 |
errval = nm1; |
161 |
return *this; |
161 |
return *this; |
162 |
} |
162 |
} |
Lines 196-204
Link Here
|
196 |
*/ |
196 |
*/ |
197 |
template <class T> |
197 |
template <class T> |
198 |
T LUMatrix<T>::determinant(){ |
198 |
T LUMatrix<T>::determinant(){ |
199 |
T det = elem(0,0) ; |
199 |
T det = this->elem(0,0) ; |
200 |
for(int i=1;i<rows();++i) |
200 |
for(int i=1;i<this->rows();++i) |
201 |
det *= elem(i,i) ; |
201 |
det *= this->elem(i,i) ; |
202 |
return det * (T)sign ; |
202 |
return det * (T)sign ; |
203 |
} |
203 |
} |
204 |
|
204 |
|
Lines 253-262
Link Here
|
253 |
T ten; |
253 |
T ten; |
254 |
int i, j, k, l, kb, kp1, nm1, n, coln; |
254 |
int i, j, k, l, kb, kp1, nm1, n, coln; |
255 |
|
255 |
|
256 |
if ( rows() != cols() ) |
256 |
if ( this->rows() != this->cols() ) |
257 |
{ |
257 |
{ |
258 |
#ifdef USE_EXCEPTION |
258 |
#ifdef USE_EXCEPTION |
259 |
throw WrongSize2D(rows(),cols(),0,0) ; |
259 |
throw WrongSize2D(this->rows(),this->cols(),0,0) ; |
260 |
#else |
260 |
#else |
261 |
Error error("invm"); |
261 |
Error error("invm"); |
262 |
error << "matrix inverse, not square: " << rows() << " by " << cols() << endl; |
262 |
error << "matrix inverse, not square: " << rows() << " by " << cols() << endl; |
Lines 264-270
Link Here
|
264 |
#endif |
264 |
#endif |
265 |
} |
265 |
} |
266 |
|
266 |
|
267 |
n = coln = rows(); |
267 |
n = coln = this->rows(); |
268 |
|
268 |
|
269 |
|
269 |
|
270 |
inv = *this ; |
270 |
inv = *this ; |
Lines 338-347
Link Here
|
338 |
template <class T> |
338 |
template <class T> |
339 |
Matrix<T> LUMatrix<T>::inverse() |
339 |
Matrix<T> LUMatrix<T>::inverse() |
340 |
{ |
340 |
{ |
341 |
if ( rows() != cols() ) |
341 |
if ( this->rows() != this->cols() ) |
342 |
{ |
342 |
{ |
343 |
#ifdef USE_EXCEPTION |
343 |
#ifdef USE_EXCEPTION |
344 |
throw WrongSize2D(rows(),cols(),0,0) ; |
344 |
throw WrongSize2D(this->rows(),this->cols(),0,0) ; |
345 |
#else |
345 |
#else |
346 |
Error error("invm"); |
346 |
Error error("invm"); |
347 |
error << "matrix inverse, not square: " << rows() << " by " << cols() << endl; |
347 |
error << "matrix inverse, not square: " << rows() << " by " << cols() << endl; |
348 |
-- nurbs/d_nurbsSub.cpp.old |
348 |
++ nurbs/d_nurbsSub.cpp |
Lines 14-21
Link Here
|
14 |
template class RenderMeshPoints<double> ; |
14 |
template class RenderMeshPoints<double> ; |
15 |
|
15 |
|
16 |
|
16 |
|
17 |
double NurbSurface<double>::epsilon = 1e-6 ; |
17 |
template <> double NurbSurface<double>::epsilon = 1e-6 ; |
18 |
double SurfSample<double>::epsilon = 1e-6 ; |
18 |
template <> double SurfSample<double>::epsilon = 1e-6 ; |
19 |
|
19 |
|
20 |
template void DrawSubdivision( NurbSurface<double> *, double tolerance ); |
20 |
template void DrawSubdivision( NurbSurface<double> *, double tolerance ); |
21 |
template void DrawEvaluation( NurbSurface<double> * ); |
21 |
template void DrawEvaluation( NurbSurface<double> * ); |
22 |
-- nurbs/f_nurbsSub.cpp.old |
22 |
++ nurbs/f_nurbsSub.cpp |
Lines 14-21
Link Here
|
14 |
template class RenderMeshPoints<float> ; |
14 |
template class RenderMeshPoints<float> ; |
15 |
|
15 |
|
16 |
|
16 |
|
17 |
float NurbSurface<float>::epsilon = 1e-6 ; |
17 |
template <> float NurbSurface<float>::epsilon = 1e-6 ; |
18 |
float SurfSample<float>::epsilon = 1e-6 ; |
18 |
template <> float SurfSample<float>::epsilon = 1e-6 ; |
19 |
|
19 |
|
20 |
template void DrawSubdivision( NurbSurface<float> *, float tolerance ); |
20 |
template void DrawSubdivision( NurbSurface<float> *, float tolerance ); |
21 |
template void DrawEvaluation( NurbSurface<float> * ); |
21 |
template void DrawEvaluation( NurbSurface<float> * ); |
22 |
-- nurbs/hnurbsS.cpp.old |
22 |
++ nurbs/hnurbsS.cpp |
Lines 103-113
Link Here
|
103 |
initBase() ; |
103 |
initBase() ; |
104 |
offset.resize(baseSurf.ctrlPnts()) ; |
104 |
offset.resize(baseSurf.ctrlPnts()) ; |
105 |
|
105 |
|
106 |
P = baseSurf.ctrlPnts() ; |
106 |
this->P = baseSurf.ctrlPnts() ; |
107 |
U = baseSurf.knotU() ; |
107 |
this->U = baseSurf.knotU() ; |
108 |
V = baseSurf.knotV() ; |
108 |
this->V = baseSurf.knotV() ; |
109 |
degU = baseSurf.degreeU() ; |
109 |
this->degU = baseSurf.degreeU() ; |
110 |
degV = baseSurf.degreeV() ; |
110 |
this->degV = baseSurf.degreeV() ; |
111 |
|
111 |
|
112 |
//updateSurface() ; |
112 |
//updateSurface() ; |
113 |
|
113 |
|
Lines 162-172
Link Here
|
162 |
baseUpdateN = baseLevel_->modifiedN()-1 ; // Set it so that initBase will run |
162 |
baseUpdateN = baseLevel_->modifiedN()-1 ; // Set it so that initBase will run |
163 |
initBase() ; |
163 |
initBase() ; |
164 |
offset.resize(baseSurf.ctrlPnts()) ; |
164 |
offset.resize(baseSurf.ctrlPnts()) ; |
165 |
P = baseSurf.ctrlPnts() ; |
165 |
this->P = baseSurf.ctrlPnts() ; |
166 |
U = baseSurf.knotU() ; |
166 |
this->U = baseSurf.knotU() ; |
167 |
V = baseSurf.knotV() ; |
167 |
this->V = baseSurf.knotV() ; |
168 |
degU = baseSurf.degreeU() ; |
168 |
this->degU = baseSurf.degreeU() ; |
169 |
degV = baseSurf.degreeV() ; |
169 |
this->degV = baseSurf.degreeV() ; |
170 |
//updateSurface() ; |
170 |
//updateSurface() ; |
171 |
|
171 |
|
172 |
} |
172 |
} |
Lines 200-206
Link Here
|
200 |
rU.resize(0) ; |
200 |
rU.resize(0) ; |
201 |
rV.resize(0) ; |
201 |
rV.resize(0) ; |
202 |
|
202 |
|
203 |
offset = P ; |
203 |
offset = this->P ; |
204 |
} |
204 |
} |
205 |
|
205 |
|
206 |
/*! |
206 |
/*! |
Lines 334-344
Link Here
|
334 |
} |
334 |
} |
335 |
if(baseLevel_){ |
335 |
if(baseLevel_){ |
336 |
if(initBase()){ |
336 |
if(initBase()){ |
337 |
P = baseSurf.ctrlPnts() ; |
337 |
this->P = baseSurf.ctrlPnts() ; |
338 |
U = baseSurf.knotU() ; |
338 |
this->U = baseSurf.knotU() ; |
339 |
V = baseSurf.knotV() ; |
339 |
this->V = baseSurf.knotV() ; |
340 |
degU = baseSurf.degreeU() ; |
340 |
this->degU = baseSurf.degreeU() ; |
341 |
degV = baseSurf.degreeV() ; |
341 |
this->degV = baseSurf.degreeV() ; |
342 |
} |
342 |
} |
343 |
if(i0>=0 && j0>=0){ |
343 |
if(i0>=0 && j0>=0){ |
344 |
Point_nD<T,N> vecOffset ; |
344 |
Point_nD<T,N> vecOffset ; |
Lines 352-364
Link Here
|
352 |
offset(i0,j0).y()*jvec(i0,j0) + |
352 |
offset(i0,j0).y()*jvec(i0,j0) + |
353 |
offset(i0,j0).z()*kvec(i0,j0) ; |
353 |
offset(i0,j0).z()*kvec(i0,j0) ; |
354 |
} |
354 |
} |
355 |
P(i0,j0).x() = baseSurf.ctrlPnts()(i0,j0).x()+vecOffset.x() ; |
355 |
this->P(i0,j0).x() = baseSurf.ctrlPnts()(i0,j0).x()+vecOffset.x() ; |
356 |
P(i0,j0).y() = baseSurf.ctrlPnts()(i0,j0).y()+vecOffset.y() ; |
356 |
this->P(i0,j0).y() = baseSurf.ctrlPnts()(i0,j0).y()+vecOffset.y() ; |
357 |
P(i0,j0).z() = baseSurf.ctrlPnts()(i0,j0).z()+vecOffset.z() ; |
357 |
this->P(i0,j0).z() = baseSurf.ctrlPnts()(i0,j0).z()+vecOffset.z() ; |
358 |
} |
358 |
} |
359 |
else{ |
359 |
else{ |
360 |
for(int i=0;i<P.rows();++i) |
360 |
for(int i=0;i<this->P.rows();++i) |
361 |
for(int j=0;j<P.cols();++j){ |
361 |
for(int j=0;j<this->P.cols();++j){ |
362 |
if(offset(i,j).x() != 0 || |
362 |
if(offset(i,j).x() != 0 || |
363 |
offset(i,j).y() != 0 || offset(i,j).z() || 0){ |
363 |
offset(i,j).y() != 0 || offset(i,j).z() || 0){ |
364 |
Point_nD<T,N> vecOffset ; |
364 |
Point_nD<T,N> vecOffset ; |
Lines 372-391
Link Here
|
372 |
offset(i,j).y()*jvec(i,j) + |
372 |
offset(i,j).y()*jvec(i,j) + |
373 |
offset(i,j).z()*kvec(i,j) ; |
373 |
offset(i,j).z()*kvec(i,j) ; |
374 |
} |
374 |
} |
375 |
P(i,j).x() = baseSurf.ctrlPnts()(i,j).x()+vecOffset.x() ; |
375 |
this->P(i,j).x() = baseSurf.ctrlPnts()(i,j).x()+vecOffset.x() ; |
376 |
P(i,j).y() = baseSurf.ctrlPnts()(i,j).y()+vecOffset.y() ; |
376 |
this->P(i,j).y() = baseSurf.ctrlPnts()(i,j).y()+vecOffset.y() ; |
377 |
P(i,j).z() = baseSurf.ctrlPnts()(i,j).z()+vecOffset.z() ; |
377 |
this->P(i,j).z() = baseSurf.ctrlPnts()(i,j).z()+vecOffset.z() ; |
378 |
} |
378 |
} |
379 |
} |
379 |
} |
380 |
} |
380 |
} |
381 |
} |
381 |
} |
382 |
else{ |
382 |
else{ |
383 |
if(i0>=0 && j0>=0) |
383 |
if(i0>=0 && j0>=0) |
384 |
P(i0,j0) = offset(i0,j0) ; |
384 |
this->P(i0,j0) = offset(i0,j0) ; |
385 |
else{ |
385 |
else{ |
386 |
for(int i=0;i<P.rows();++i) |
386 |
for(int i=0;i<this->P.rows();++i) |
387 |
for(int j=0;j<P.cols();++j){ |
387 |
for(int j=0;j<this->P.cols();++j){ |
388 |
P(i,j) = offset(i,j) ; |
388 |
this->P(i,j) = offset(i,j) ; |
389 |
} |
389 |
} |
390 |
} |
390 |
} |
391 |
} |
391 |
} |
Lines 554-570
Link Here
|
554 |
return mod ; |
554 |
return mod ; |
555 |
} |
555 |
} |
556 |
|
556 |
|
557 |
if(u<knotU()[0] || u>knotU()[knotU().n()-1]) |
557 |
if(u<this->knotU()[0] || u>this->knotU()[this->knotU().n()-1]) |
558 |
return -1 ; |
558 |
return -1 ; |
559 |
if(v<knotV()[0] || v>knotU()[knotV().n()-1]) |
559 |
if(v<this->knotV()[0] || v>this->knotU()[this->knotV().n()-1]) |
560 |
return -1 ; |
560 |
return -1 ; |
561 |
|
561 |
|
562 |
int su = findSpanU(u) ; |
562 |
int su = findSpanU(u) ; |
563 |
int sv = findSpanV(v) ; |
563 |
int sv = findSpanV(v) ; |
564 |
|
564 |
|
565 |
for(int i=0;i<=degU;++i) |
565 |
for(int i=0;i<=this->degU;++i) |
566 |
for(int j=0;j<=degV;++j){ |
566 |
for(int j=0;j<=this->degV;++j){ |
567 |
if(offset(su-degU+i,sv+degV+j) != HPoint_nD<T,N>(0,0,0,0)) |
567 |
if(offset(su-this->degU+i,sv+this->degV+j) != HPoint_nD<T,N>(0,0,0,0)) |
568 |
return level_ ; |
568 |
return level_ ; |
569 |
} |
569 |
} |
570 |
|
570 |
|
Lines 742-757
Link Here
|
742 |
template <class T, int N> |
742 |
template <class T, int N> |
743 |
void HNurbsSurface<T,N>::splitUV(int nu, int nv, Vector<T> &nU, Vector<T> &nV){ |
743 |
void HNurbsSurface<T,N>::splitUV(int nu, int nv, Vector<T> &nU, Vector<T> &nV){ |
744 |
|
744 |
|
745 |
nU.resize(knotU().n()*nu) ; |
745 |
nU.resize(this->knotU().n()*nu) ; |
746 |
nV.resize(knotV().n()*nv) ; |
746 |
nV.resize(this->knotV().n()*nv) ; |
747 |
|
747 |
|
748 |
int i,j,n ; |
748 |
int i,j,n ; |
749 |
|
749 |
|
750 |
n = 0 ; |
750 |
n = 0 ; |
751 |
for(i=1;i<knotU().n();++i){ |
751 |
for(i=1;i<this->knotU().n();++i){ |
752 |
if(knotU()[i] >knotU()[i-1]){ |
752 |
if(this->knotU()[i] >this->knotU()[i-1]){ |
753 |
T a = knotU()[i-1] ; |
753 |
T a = this->knotU()[i-1] ; |
754 |
T b = knotU()[i] ; |
754 |
T b = this->knotU()[i] ; |
755 |
|
755 |
|
756 |
|
756 |
|
757 |
for(j=0;j<nu;++j){ |
757 |
for(j=0;j<nu;++j){ |
Lines 763-772
Link Here
|
763 |
nU.resize(n) ; |
763 |
nU.resize(n) ; |
764 |
|
764 |
|
765 |
n = 0 ; |
765 |
n = 0 ; |
766 |
for(i=1;i<knotV().n();++i){ |
766 |
for(i=1;i<this->knotV().n();++i){ |
767 |
if(knotV()[i] > knotV()[i-1]){ |
767 |
if(this->knotV()[i] > this->knotV()[i-1]){ |
768 |
T a = knotV()[i-1] ; |
768 |
T a = this->knotV()[i-1] ; |
769 |
T b = knotV()[i] ; |
769 |
T b = this->knotV()[i] ; |
770 |
|
770 |
|
771 |
for(j=0;j<nv;++j){ |
771 |
for(j=0;j<nv;++j){ |
772 |
nV[n] = a + (b-a)*T(j+1)/T(nv+1) ; |
772 |
nV[n] = a + (b-a)*T(j+1)/T(nv+1) ; |
Lines 805-826
Link Here
|
805 |
int i,j,n ; |
805 |
int i,j,n ; |
806 |
|
806 |
|
807 |
if(su<=0) |
807 |
if(su<=0) |
808 |
su = degU ; |
808 |
su = this->degU ; |
809 |
if(sv<=0) |
809 |
if(sv<=0) |
810 |
sv = degV ; |
810 |
sv = this->degV ; |
811 |
if(su>degU+1) |
811 |
if(su>this->degU+1) |
812 |
su = degU+1 ; |
812 |
su = this->degU+1 ; |
813 |
if(sv>degV+1) |
813 |
if(sv>this->degV+1) |
814 |
sv = degV+1 ; |
814 |
sv = this->degV+1 ; |
815 |
|
815 |
|
816 |
nU.resize(knotU().n()*nu*su) ; |
816 |
nU.resize(this->knotU().n()*nu*su) ; |
817 |
nV.resize(knotV().n()*nv*sv) ; |
817 |
nV.resize(this->knotV().n()*nv*sv) ; |
818 |
|
818 |
|
819 |
n = 0 ; |
819 |
n = 0 ; |
820 |
for(i=1;i<knotU().n();++i){ |
820 |
for(i=1;i<this->knotU().n();++i){ |
821 |
if(knotU()[i] >knotU()[i-1]){ |
821 |
if(this->knotU()[i] >this->knotU()[i-1]){ |
822 |
T a = knotU()[i-1] ; |
822 |
T a = this->knotU()[i-1] ; |
823 |
T b = knotU()[i] ; |
823 |
T b = this->knotU()[i] ; |
824 |
|
824 |
|
825 |
|
825 |
|
826 |
for(j=0;j<nu;++j){ |
826 |
for(j=0;j<nu;++j){ |
Lines 835-844
Link Here
|
835 |
nU.resize(n) ; |
835 |
nU.resize(n) ; |
836 |
|
836 |
|
837 |
n = 0 ; |
837 |
n = 0 ; |
838 |
for(i=1;i<knotV().n();++i){ |
838 |
for(i=1;i<this->knotV().n();++i){ |
839 |
if(knotV()[i] > knotV()[i-1]){ |
839 |
if(this->knotV()[i] > this->knotV()[i-1]){ |
840 |
T a = knotV()[i-1] ; |
840 |
T a = this->knotV()[i-1] ; |
841 |
T b = knotV()[i] ; |
841 |
T b = this->knotV()[i] ; |
842 |
|
842 |
|
843 |
for(j=0;j<nv;++j){ |
843 |
for(j=0;j<nv;++j){ |
844 |
T v = a + (b-a)*T(j+1)/T(nv+1) ; |
844 |
T v = a + (b-a)*T(j+1)/T(nv+1) ; |
Lines 1014-1023
Link Here
|
1014 |
if(!fin.read((char*)&du,sizeof(int))) { delete []type ; return 0 ;} |
1014 |
if(!fin.read((char*)&du,sizeof(int))) { delete []type ; return 0 ;} |
1015 |
if(!fin.read((char*)&dv,sizeof(int))) { delete []type ; return 0 ;} |
1015 |
if(!fin.read((char*)&dv,sizeof(int))) { delete []type ; return 0 ;} |
1016 |
|
1016 |
|
1017 |
resize(nu,nv,du,dv) ; |
1017 |
this->resize(nu,nv,du,dv) ; |
1018 |
|
1018 |
|
1019 |
if(!fin.read((char*)U.memory(),sizeof(T)*U.n())) { delete []type ; return 0 ;} |
1019 |
if(!fin.read((char*)this->U.memory(),sizeof(T)*this->U.n())) { delete []type ; return 0 ;} |
1020 |
if(!fin.read((char*)V.memory(),sizeof(T)*V.n())) { delete []type ; return 0 ;} |
1020 |
if(!fin.read((char*)this->V.memory(),sizeof(T)*this->V.n())) { delete []type ; return 0 ;} |
1021 |
|
1021 |
|
1022 |
if(!r1){ |
1022 |
if(!r1){ |
1023 |
p = new T[3*nu*nv] ; |
1023 |
p = new T[3*nu*nv] ; |
Lines 1025-1034
Link Here
|
1025 |
p2 = p ; |
1025 |
p2 = p ; |
1026 |
for(int i=0;i<nu;i++) |
1026 |
for(int i=0;i<nu;i++) |
1027 |
for(int j=0;j<nv;j++){ |
1027 |
for(int j=0;j<nv;j++){ |
1028 |
P(i,j).x() = *(p++) ; |
1028 |
this->P(i,j).x() = *(p++) ; |
1029 |
P(i,j).y() = *(p++) ; |
1029 |
this->P(i,j).y() = *(p++) ; |
1030 |
P(i,j).z() = *(p++) ; |
1030 |
this->P(i,j).z() = *(p++) ; |
1031 |
P(i,j).w() = 1.0 ; |
1031 |
this->P(i,j).w() = 1.0 ; |
1032 |
} |
1032 |
} |
1033 |
delete []p2 ; |
1033 |
delete []p2 ; |
1034 |
} |
1034 |
} |
Lines 1038-1051
Link Here
|
1038 |
p2 = p ; |
1038 |
p2 = p ; |
1039 |
for(int i=0;i<nu;i++) |
1039 |
for(int i=0;i<nu;i++) |
1040 |
for(int j=0;j<nv;j++){ |
1040 |
for(int j=0;j<nv;j++){ |
1041 |
P(i,j).x() = *(p++) ; |
1041 |
this->P(i,j).x() = *(p++) ; |
1042 |
P(i,j).y() = *(p++) ; |
1042 |
this->P(i,j).y() = *(p++) ; |
1043 |
P(i,j).z() = *(p++) ; |
1043 |
this->P(i,j).z() = *(p++) ; |
1044 |
P(i,j).w() = *(p++) ; |
1044 |
this->P(i,j).w() = *(p++) ; |
1045 |
} |
1045 |
} |
1046 |
delete []p2 ; |
1046 |
delete []p2 ; |
1047 |
} |
1047 |
} |
1048 |
offset = P ; |
1048 |
offset = this->P ; |
1049 |
this->updateSurface() ; |
1049 |
this->updateSurface() ; |
1050 |
} |
1050 |
} |
1051 |
else { // reading the offset information |
1051 |
else { // reading the offset information |
Lines 1144-1172
Link Here
|
1144 |
if(!fout) |
1144 |
if(!fout) |
1145 |
return 0 ; |
1145 |
return 0 ; |
1146 |
if(!baseLevel_){ |
1146 |
if(!baseLevel_){ |
1147 |
int prows = P.rows(); |
1147 |
int prows = this->P.rows(); |
1148 |
int pcols = P.cols(); |
1148 |
int pcols = this->P.cols(); |
1149 |
char st = '0' + sizeof(T) ; |
1149 |
char st = '0' + sizeof(T) ; |
1150 |
if(!fout.write((char*)&"hns4",sizeof(char)*4)) return 0 ; |
1150 |
if(!fout.write((char*)&"hns4",sizeof(char)*4)) return 0 ; |
1151 |
if(!fout.write((char*)&st,sizeof(char))) return 0 ; |
1151 |
if(!fout.write((char*)&st,sizeof(char))) return 0 ; |
1152 |
if(!fout.write((char*)&prows,sizeof(int))) return 0 ; |
1152 |
if(!fout.write((char*)&prows,sizeof(int))) return 0 ; |
1153 |
if(!fout.write((char*)&pcols,sizeof(int))) return 0 ; |
1153 |
if(!fout.write((char*)&pcols,sizeof(int))) return 0 ; |
1154 |
if(!fout.write((char*)°U,sizeof(int))) return 0 ; |
1154 |
if(!fout.write((char*)&this->degU,sizeof(int))) return 0 ; |
1155 |
if(!fout.write((char*)°V,sizeof(int))) return 0 ; |
1155 |
if(!fout.write((char*)&this->degV,sizeof(int))) return 0 ; |
1156 |
if(!fout.write((char*)U.memory(),sizeof(T)*U.n())) return 0 ; |
1156 |
if(!fout.write((char*)this->U.memory(),sizeof(T)*this->U.n())) return 0 ; |
1157 |
if(!fout.write((char*)V.memory(),sizeof(T)*V.n())) return 0 ; |
1157 |
if(!fout.write((char*)this->V.memory(),sizeof(T)*this->V.n())) return 0 ; |
1158 |
|
1158 |
|
1159 |
T *p,*p2 ; |
1159 |
T *p,*p2 ; |
1160 |
p = new T[P.rows()*P.cols()*4] ; |
1160 |
p = new T[this->P.rows()*this->P.cols()*4] ; |
1161 |
p2 = p ; |
1161 |
p2 = p ; |
1162 |
for(int i=0;i<P.rows();i++) |
1162 |
for(int i=0;i<this->P.rows();i++) |
1163 |
for(int j=0;j<P.cols();j++){ |
1163 |
for(int j=0;j<this->P.cols();j++){ |
1164 |
*p = offset(i,j).x() ; p++ ; |
1164 |
*p = offset(i,j).x() ; p++ ; |
1165 |
*p = offset(i,j).y() ; p++ ; |
1165 |
*p = offset(i,j).y() ; p++ ; |
1166 |
*p = offset(i,j).z() ; p++ ; |
1166 |
*p = offset(i,j).z() ; p++ ; |
1167 |
*p = offset(i,j).w() ; p++ ; |
1167 |
*p = offset(i,j).w() ; p++ ; |
1168 |
} |
1168 |
} |
1169 |
if(!fout.write((char*)p2,sizeof(T)*P.rows()*P.cols()*4)) return 0 ; |
1169 |
if(!fout.write((char*)p2,sizeof(T)*this->P.rows()*this->P.cols()*4)) return 0 ; |
1170 |
delete []p2 ; |
1170 |
delete []p2 ; |
1171 |
} |
1171 |
} |
1172 |
else{ |
1172 |
else{ |
Lines 1282-1288
Link Here
|
1282 |
int i,j ; |
1282 |
int i,j ; |
1283 |
j = 0 ; |
1283 |
j = 0 ; |
1284 |
for(i=0;i<X.n();++i){ |
1284 |
for(i=0;i<X.n();++i){ |
1285 |
if(X[i]>=U[0] && X[i]<=U[U.n()-1]){ |
1285 |
if(X[i]>=this->U[0] && X[i]<=this->U[this->U.n()-1]){ |
1286 |
Xu[j] = X[i] ; |
1286 |
Xu[j] = X[i] ; |
1287 |
++j ; |
1287 |
++j ; |
1288 |
} |
1288 |
} |
Lines 1294-1300
Link Here
|
1294 |
nextLevel_->refineKnotU(Xu) ; |
1294 |
nextLevel_->refineKnotU(Xu) ; |
1295 |
} |
1295 |
} |
1296 |
|
1296 |
|
1297 |
NurbsSurface<T,N> osurf(degU,degV,U,V,offset) ; |
1297 |
NurbsSurface<T,N> osurf(this->degU,this->degV,this->U,this->V,offset) ; |
1298 |
|
1298 |
|
1299 |
osurf.refineKnotU(Xu) ; |
1299 |
osurf.refineKnotU(Xu) ; |
1300 |
|
1300 |
|
Lines 1324-1330
Link Here
|
1324 |
int i,j ; |
1324 |
int i,j ; |
1325 |
j = 0 ; |
1325 |
j = 0 ; |
1326 |
for(i=0;i<X.n();++i){ |
1326 |
for(i=0;i<X.n();++i){ |
1327 |
if(X[i]>=V[0] && X[i]<=V[V.n()-1]){ |
1327 |
if(X[i]>=this->V[0] && X[i]<=this->V[this->V.n()-1]){ |
1328 |
Xv[j] = X[i] ; |
1328 |
Xv[j] = X[i] ; |
1329 |
++j ; |
1329 |
++j ; |
1330 |
} |
1330 |
} |
Lines 1336-1342
Link Here
|
1336 |
nextLevel_->refineKnotV(Xv) ; |
1336 |
nextLevel_->refineKnotV(Xv) ; |
1337 |
} |
1337 |
} |
1338 |
|
1338 |
|
1339 |
NurbsSurface<T,N> osurf(degU,degV,U,V,offset) ; |
1339 |
NurbsSurface<T,N> osurf(this->degU,this->degV,this->U,this->V,offset) ; |
1340 |
|
1340 |
|
1341 |
osurf.refineKnotV(Xv) ; |
1341 |
osurf.refineKnotV(Xv) ; |
1342 |
|
1342 |
|
Lines 1370-1395
Link Here
|
1370 |
*/ |
1370 |
*/ |
1371 |
template <class T, int N> |
1371 |
template <class T, int N> |
1372 |
int HNurbsSurface<T,N>::movePointOffset(T u, T v, const Point_nD<T,N>& delta){ |
1372 |
int HNurbsSurface<T,N>::movePointOffset(T u, T v, const Point_nD<T,N>& delta){ |
1373 |
P = offset ; |
1373 |
this->P = offset ; |
1374 |
|
1374 |
|
1375 |
// by definition the offset has w = 0 , but this isn't valid for |
1375 |
// by definition the offset has w = 0 , but this isn't valid for |
1376 |
// the control points, increasing the w by 1, will generate a valid surface |
1376 |
// the control points, increasing the w by 1, will generate a valid surface |
1377 |
if(baseLevel_) |
1377 |
if(baseLevel_) |
1378 |
for(int i=0;i<P.rows();++i) |
1378 |
for(int i=0;i<this->P.rows();++i) |
1379 |
for(int j=0;j<P.cols();++j){ |
1379 |
for(int j=0;j<this->P.cols();++j){ |
1380 |
P(i,j).w() += T(1) ; |
1380 |
this->P(i,j).w() += T(1) ; |
1381 |
} |
1381 |
} |
1382 |
|
1382 |
|
1383 |
if(NurbsSurface<T,N>::movePoint(u,v,delta)){ |
1383 |
if(NurbsSurface<T,N>::movePoint(u,v,delta)){ |
1384 |
offset = P ; |
1384 |
offset = this->P ; |
1385 |
// need to reset the offset weights |
1385 |
// need to reset the offset weights |
1386 |
if(baseLevel_) |
1386 |
if(baseLevel_) |
1387 |
for(int i=0;i<P.rows();++i) |
1387 |
for(int i=0;i<this->P.rows();++i) |
1388 |
for(int j=0;j<P.cols();++j){ |
1388 |
for(int j=0;j<this->P.cols();++j){ |
1389 |
P(i,j).w() -= T(1) ; |
1389 |
this->P(i,j).w() -= T(1) ; |
1390 |
} |
1390 |
} |
1391 |
|
1391 |
|
1392 |
P = baseSurf.ctrlPnts() ; |
1392 |
this->P = baseSurf.ctrlPnts() ; |
1393 |
updateSurface() ; |
1393 |
updateSurface() ; |
1394 |
return 1 ; |
1394 |
return 1 ; |
1395 |
} |
1395 |
} |
1396 |
-- nurbs/hnurbsS_sp.cpp.old |
1396 |
++ nurbs/hnurbsS_sp.cpp |
Lines 43-49
Link Here
|
43 |
*/ |
43 |
*/ |
44 |
template <class T, int N> |
44 |
template <class T, int N> |
45 |
void HNurbsSurfaceSP<T,N>::updateMaxU() { |
45 |
void HNurbsSurfaceSP<T,N>::updateMaxU() { |
46 |
if(degU>3){ |
46 |
if(this->degU>3){ |
47 |
#ifdef USE_EXCEPTION |
47 |
#ifdef USE_EXCEPTION |
48 |
throw NurbsError(); |
48 |
throw NurbsError(); |
49 |
#else |
49 |
#else |
Lines 53-64
Link Here
|
53 |
#endif |
53 |
#endif |
54 |
} |
54 |
} |
55 |
else{ |
55 |
else{ |
56 |
maxU.resize(P.rows()) ; |
56 |
maxU.resize(this->P.rows()) ; |
57 |
maxAtU_.resize(P.rows()) ; |
57 |
maxAtU_.resize(this->P.rows()) ; |
58 |
for(int i=0;i<P.rows();++i){ |
58 |
for(int i=0;i<this->P.rows();++i){ |
59 |
if(!maxInfluence(i,U,degU,maxAtU_[i])) |
59 |
if(!maxInfluence(i,this->U,this->degU,maxAtU_[i])) |
60 |
cerr << "Problem in maxInfluence U!\n" ; |
60 |
cerr << "Problem in maxInfluence U!\n" ; |
61 |
maxU[i] = nurbsBasisFun(maxAtU_[i],i,degU,U) ; |
61 |
maxU[i] = nurbsBasisFun(maxAtU_[i],i,this->degU,this->U) ; |
62 |
} |
62 |
} |
63 |
|
63 |
|
64 |
} |
64 |
} |
Lines 78-84
Link Here
|
78 |
*/ |
78 |
*/ |
79 |
template <class T, int N> |
79 |
template <class T, int N> |
80 |
void HNurbsSurfaceSP<T,N>::updateMaxV() { |
80 |
void HNurbsSurfaceSP<T,N>::updateMaxV() { |
81 |
if(degV>3){ |
81 |
if(this->degV>3){ |
82 |
#ifdef USE_EXCEPTION |
82 |
#ifdef USE_EXCEPTION |
83 |
throw NurbsError(); |
83 |
throw NurbsError(); |
84 |
#else |
84 |
#else |
Lines 88-99
Link Here
|
88 |
#endif |
88 |
#endif |
89 |
} |
89 |
} |
90 |
else{ |
90 |
else{ |
91 |
maxV.resize(P.cols()) ; |
91 |
maxV.resize(this->P.cols()) ; |
92 |
maxAtV_.resize(P.cols()) ; |
92 |
maxAtV_.resize(this->P.cols()) ; |
93 |
for(int i=0;i<P.cols();++i){ |
93 |
for(int i=0;i<this->P.cols();++i){ |
94 |
if(!maxInfluence(i,V,degV,maxAtV_[i])) |
94 |
if(!maxInfluence(i,this->V,this->degV,maxAtV_[i])) |
95 |
cerr << "Problem in maxInfluence V!\n" ; |
95 |
cerr << "Problem in maxInfluence V!\n" ; |
96 |
maxV[i] = nurbsBasisFun(maxAtV_[i],i,degV,V) ; |
96 |
maxV[i] = nurbsBasisFun(maxAtV_[i],i,this->degV,this->V) ; |
97 |
} |
97 |
} |
98 |
|
98 |
|
99 |
} |
99 |
} |
Lines 113-130
Link Here
|
113 |
*/ |
113 |
*/ |
114 |
template <class T, int N> |
114 |
template <class T, int N> |
115 |
void HNurbsSurfaceSP<T,N>::modSurfCPby(int i, int j, const HPoint_nD<T,N>& a) { |
115 |
void HNurbsSurfaceSP<T,N>::modSurfCPby(int i, int j, const HPoint_nD<T,N>& a) { |
116 |
offset(i,j) += a / (maxU[i]*maxV[j]) ; |
116 |
this->offset(i,j) += a / (maxU[i]*maxV[j]) ; |
117 |
if(baseLevel_){ |
117 |
if(this->baseLevel_){ |
118 |
Point_nD<T,N> vecOffset ; |
118 |
Point_nD<T,N> vecOffset ; |
119 |
vecOffset = offset(i,j).x()*ivec(i,j) + |
119 |
vecOffset = this->offset(i,j).x()*this->ivec(i,j) + |
120 |
offset(i,j).y()*jvec(i,j) + |
120 |
this->offset(i,j).y()*this->jvec(i,j) + |
121 |
offset(i,j).z()*kvec(i,j) ; |
121 |
this->offset(i,j).z()*this->kvec(i,j) ; |
122 |
P(i,j).x() = baseSurf.ctrlPnts()(i,j).x()+vecOffset.x() ; |
122 |
this->P(i,j).x() = this->baseSurf.ctrlPnts()(i,j).x()+vecOffset.x() ; |
123 |
P(i,j).y() = baseSurf.ctrlPnts()(i,j).y()+vecOffset.y() ; |
123 |
this->P(i,j).y() = this->baseSurf.ctrlPnts()(i,j).y()+vecOffset.y() ; |
124 |
P(i,j).z() = baseSurf.ctrlPnts()(i,j).z()+vecOffset.z() ; |
124 |
this->P(i,j).z() = this->baseSurf.ctrlPnts()(i,j).z()+vecOffset.z() ; |
125 |
} |
125 |
} |
126 |
else |
126 |
else |
127 |
P(i,j) = offset(i,j) ; |
127 |
this->P(i,j) = this->offset(i,j) ; |
128 |
} |
128 |
} |
129 |
|
129 |
|
130 |
/*! |
130 |
/*! |
Lines 151-174
Link Here
|
151 |
void HNurbsSurfaceSP<T,N>::modOnlySurfCPby(int i, int j, const HPoint_nD<T,N>& a){ |
151 |
void HNurbsSurfaceSP<T,N>::modOnlySurfCPby(int i, int j, const HPoint_nD<T,N>& a){ |
152 |
int k ; |
152 |
int k ; |
153 |
|
153 |
|
154 |
P = offset ; |
154 |
this->P = this->offset ; |
155 |
|
155 |
|
156 |
// by definition the offset has w = 0 , but this isn't valid for |
156 |
// by definition the offset has w = 0 , but this isn't valid for |
157 |
// the control points, increasing the w by 1, will generate a valid surface |
157 |
// the control points, increasing the w by 1, will generate a valid surface |
158 |
if(baseLevel_) |
158 |
if(this->baseLevel_) |
159 |
for(k=0;k<P.rows();++k) |
159 |
for(k=0;k<this->P.rows();++k) |
160 |
for(int l=0;l<P.cols();++l) |
160 |
for(int l=0;l<this->P.cols();++l) |
161 |
P(k,l).w() += T(1) ; |
161 |
this->P(k,l).w() += T(1) ; |
162 |
|
162 |
|
163 |
int sizeU, sizeV ; |
163 |
int sizeU, sizeV ; |
164 |
|
164 |
|
165 |
sizeU = 2*degU+3 ; |
165 |
sizeU = 2*this->degU+3 ; |
166 |
if(i-degU-1<0) sizeU += i-degU-1 ; |
166 |
if(i-this->degU-1<0) sizeU += i-this->degU-1 ; |
167 |
if(i+degU+1>=P.rows()) sizeU -= i+degU+1-P.rows() ; |
167 |
if(i+this->degU+1>=this->P.rows()) sizeU -= i+this->degU+1-this->P.rows() ; |
168 |
|
168 |
|
169 |
sizeV = 2*degV+3 ; |
169 |
sizeV = 2*this->degV+3 ; |
170 |
if(j-degV-1<0) sizeV += j-degV-1 ; |
170 |
if(j-this->degV-1<0) sizeV += j-this->degV-1 ; |
171 |
if(j+degV+1>=P.cols()) sizeV -= j+degV+1-P.cols() ; |
171 |
if(j+this->degV+1>=this->P.cols()) sizeV -= j+this->degV+1-this->P.cols() ; |
172 |
|
172 |
|
173 |
Vector<T> u(sizeU) ; |
173 |
Vector<T> u(sizeU) ; |
174 |
Vector<T> v(sizeV) ; |
174 |
Vector<T> v(sizeV) ; |
Lines 179-194
Link Here
|
179 |
int n=0; |
179 |
int n=0; |
180 |
int nu = 0 ; |
180 |
int nu = 0 ; |
181 |
int nv = 0 ; |
181 |
int nv = 0 ; |
182 |
for(k=i-degU-1;k<=i+degU+1;++k){ |
182 |
for(k=i-this->degU-1;k<=i+this->degU+1;++k){ |
183 |
if(k<0) |
183 |
if(k<0) |
184 |
continue ; |
184 |
continue ; |
185 |
if(k>=P.rows()) |
185 |
if(k>=this->P.rows()) |
186 |
break ; |
186 |
break ; |
187 |
nv = 0 ; |
187 |
nv = 0 ; |
188 |
for(int l=j-degV-1;l<=j+degV+1;++l){ |
188 |
for(int l=j-this->degV-1;l<=j+this->degV+1;++l){ |
189 |
if(l<0) |
189 |
if(l<0) |
190 |
continue ; |
190 |
continue ; |
191 |
if(l>=P.cols()) |
191 |
if(l>=this->P.cols()) |
192 |
break ; |
192 |
break ; |
193 |
if( k == i && j==l){ |
193 |
if( k == i && j==l){ |
194 |
pts[n].x() = a.x() ; |
194 |
pts[n].x() = a.x() ; |
Lines 216-227
Link Here
|
216 |
pv.resize(n) ; |
216 |
pv.resize(n) ; |
217 |
|
217 |
|
218 |
if(NurbsSurface<T,N>::movePoint(u,v,pts,pu,pv)){ |
218 |
if(NurbsSurface<T,N>::movePoint(u,v,pts,pu,pv)){ |
219 |
offset = P ; |
219 |
this->offset = this->P ; |
220 |
// an offset shouldn't have a weight value. |
220 |
// an offset shouldn't have a weight value. |
221 |
if(baseLevel_) |
221 |
if(this->baseLevel_) |
222 |
for(k=0;k<P.rows();++k) |
222 |
for(k=0;k<this->P.rows();++k) |
223 |
for(int l=0;l<P.cols();++l) |
223 |
for(int l=0;l<this->P.cols();++l) |
224 |
offset(k,l).w() -= T(1) ; |
224 |
this->offset(k,l).w() -= T(1) ; |
225 |
} |
225 |
} |
226 |
updateSurface(); |
226 |
updateSurface(); |
227 |
} |
227 |
} |
Lines 262-268
Link Here
|
262 |
HNurbsSurfaceSP<T,N>* HNurbsSurfaceSP<T,N>::addLevel(int n, int s) { |
262 |
HNurbsSurfaceSP<T,N>* HNurbsSurfaceSP<T,N>::addLevel(int n, int s) { |
263 |
HNurbsSurfaceSP<T,N> *newLevel ; |
263 |
HNurbsSurfaceSP<T,N> *newLevel ; |
264 |
|
264 |
|
265 |
if(nextLevel_) |
265 |
if(this->nextLevel_) |
266 |
return 0 ; |
266 |
return 0 ; |
267 |
|
267 |
|
268 |
Vector<T> newU,newV ; |
268 |
Vector<T> newU,newV ; |
Lines 289-295
Link Here
|
289 |
HNurbsSurfaceSP<T,N>* HNurbsSurfaceSP<T,N>::addLevel() { |
289 |
HNurbsSurfaceSP<T,N>* HNurbsSurfaceSP<T,N>::addLevel() { |
290 |
HNurbsSurfaceSP<T,N> *newLevel ; |
290 |
HNurbsSurfaceSP<T,N> *newLevel ; |
291 |
|
291 |
|
292 |
if(nextLevel_) |
292 |
if(this->nextLevel_) |
293 |
return 0 ; |
293 |
return 0 ; |
294 |
|
294 |
|
295 |
newLevel = new HNurbsSurfaceSP<T,N>(this) ; |
295 |
newLevel = new HNurbsSurfaceSP<T,N>(this) ; |
Lines 311-333
Link Here
|
311 |
levelP = nS.nextLevel() ; |
311 |
levelP = nS.nextLevel() ; |
312 |
|
312 |
|
313 |
NurbsSurface<T,N>::operator=(nS) ; |
313 |
NurbsSurface<T,N>::operator=(nS) ; |
314 |
rU = nS.rU ; |
314 |
this->rU = nS.rU ; |
315 |
rV = nS.rV ; |
315 |
this->rV = nS.rV ; |
316 |
offset = nS.offset ; |
316 |
this->offset = nS.offset ; |
317 |
|
317 |
|
318 |
updateMaxUV() ; |
318 |
updateMaxUV() ; |
319 |
|
319 |
|
320 |
firstLevel_ = this ; |
320 |
this->firstLevel_ = this ; |
321 |
|
321 |
|
322 |
if(levelP){ |
322 |
if(levelP){ |
323 |
HNurbsSurfaceSP<T,N> *newLevel ; |
323 |
HNurbsSurfaceSP<T,N> *newLevel ; |
324 |
newLevel = new HNurbsSurfaceSP<T,N>(this) ; |
324 |
newLevel = new HNurbsSurfaceSP<T,N>(this) ; |
325 |
newLevel->copy(*levelP) ; |
325 |
newLevel->copy(*levelP) ; |
326 |
nextLevel_ = newLevel ; |
326 |
this->nextLevel_ = newLevel ; |
327 |
lastLevel_ = nextLevel_->lastLevel() ; |
327 |
this->lastLevel_ = this->nextLevel_->lastLevel() ; |
328 |
} |
328 |
} |
329 |
else{ |
329 |
else{ |
330 |
lastLevel_ = this ; |
330 |
this->lastLevel_ = this ; |
331 |
} |
331 |
} |
332 |
|
332 |
|
333 |
} |
333 |
} |
Lines 349-403
Link Here
|
349 |
template <class T, int N> |
349 |
template <class T, int N> |
350 |
void HNurbsSurfaceSP<T,N>::updateSurface(int i0, int j0){ |
350 |
void HNurbsSurfaceSP<T,N>::updateSurface(int i0, int j0){ |
351 |
if(i0>=0 && j0>=0){ |
351 |
if(i0>=0 && j0>=0){ |
352 |
if(offset(i0,j0).x()==0.0 && offset(i0,j0).y()==0.0 && offset(i0,j0).z()==0.0) |
352 |
if(this->offset(i0,j0).x()==0.0 && this->offset(i0,j0).y()==0.0 && this->offset(i0,j0).z()==0.0) |
353 |
return ; |
353 |
return ; |
354 |
} |
354 |
} |
355 |
if(baseLevel_){ |
355 |
if(this->baseLevel_){ |
356 |
if(initBase()){ |
356 |
if(this->initBase()){ |
357 |
P = baseSurf.ctrlPnts() ; |
357 |
this->P = this->baseSurf.ctrlPnts() ; |
358 |
U = baseSurf.knotU() ; |
358 |
this->U = this->baseSurf.knotU() ; |
359 |
V = baseSurf.knotV() ; |
359 |
this->V = this->baseSurf.knotV() ; |
360 |
degU = baseSurf.degreeU() ; |
360 |
this->degU = this->baseSurf.degreeU() ; |
361 |
degV = baseSurf.degreeV() ; |
361 |
this->degV = this->baseSurf.degreeV() ; |
362 |
updateMaxUV() ; |
362 |
updateMaxUV() ; |
363 |
} |
363 |
} |
364 |
if(i0>=0 && j0>=0){ |
364 |
if(i0>=0 && j0>=0){ |
365 |
Point_nD<T,N> vecOffset ; |
365 |
Point_nD<T,N> vecOffset ; |
366 |
vecOffset = offset(i0,j0).x()*ivec(i0,j0) + |
366 |
vecOffset = this->offset(i0,j0).x()*this->ivec(i0,j0) + |
367 |
offset(i0,j0).y()*jvec(i0,j0) + |
367 |
this->offset(i0,j0).y()*this->jvec(i0,j0) + |
368 |
offset(i0,j0).z()*kvec(i0,j0) ; |
368 |
this->offset(i0,j0).z()*this->kvec(i0,j0) ; |
369 |
P(i0,j0).x() = baseSurf.ctrlPnts()(i0,j0).x()+vecOffset.x() ; |
369 |
this->P(i0,j0).x() = this->baseSurf.ctrlPnts()(i0,j0).x()+vecOffset.x() ; |
370 |
P(i0,j0).y() = baseSurf.ctrlPnts()(i0,j0).y()+vecOffset.y() ; |
370 |
this->P(i0,j0).y() = this->baseSurf.ctrlPnts()(i0,j0).y()+vecOffset.y() ; |
371 |
P(i0,j0).z() = baseSurf.ctrlPnts()(i0,j0).z()+vecOffset.z() ; |
371 |
this->P(i0,j0).z() = this->baseSurf.ctrlPnts()(i0,j0).z()+vecOffset.z() ; |
372 |
} |
372 |
} |
373 |
else{ |
373 |
else{ |
374 |
for(int i=0;i<P.rows();++i) |
374 |
for(int i=0;i<this->P.rows();++i) |
375 |
for(int j=0;j<P.cols();++j){ |
375 |
for(int j=0;j<this->P.cols();++j){ |
376 |
if(offset(i,j).x() != 0 || |
376 |
if(this->offset(i,j).x() != 0 || |
377 |
offset(i,j).y() != 0 || offset(i,j).z() || 0){ |
377 |
this->offset(i,j).y() != 0 || this->offset(i,j).z() || 0){ |
378 |
Point_nD<T,N> vecOffset ; |
378 |
Point_nD<T,N> vecOffset ; |
379 |
vecOffset = offset(i,j).x()*ivec(i,j) + |
379 |
vecOffset = this->offset(i,j).x()*this->ivec(i,j) + |
380 |
offset(i,j).y()*jvec(i,j) + |
380 |
this->offset(i,j).y()*this->jvec(i,j) + |
381 |
offset(i,j).z()*kvec(i,j) ; |
381 |
this->offset(i,j).z()*this->kvec(i,j) ; |
382 |
P(i,j).x() = baseSurf.ctrlPnts()(i,j).x()+vecOffset.x() ; |
382 |
this->P(i,j).x() = this->baseSurf.ctrlPnts()(i,j).x()+vecOffset.x() ; |
383 |
P(i,j).y() = baseSurf.ctrlPnts()(i,j).y()+vecOffset.y() ; |
383 |
this->P(i,j).y() = this->baseSurf.ctrlPnts()(i,j).y()+vecOffset.y() ; |
384 |
P(i,j).z() = baseSurf.ctrlPnts()(i,j).z()+vecOffset.z() ; |
384 |
this->P(i,j).z() = this->baseSurf.ctrlPnts()(i,j).z()+vecOffset.z() ; |
385 |
} |
385 |
} |
386 |
} |
386 |
} |
387 |
} |
387 |
} |
388 |
} |
388 |
} |
389 |
else{ |
389 |
else{ |
390 |
if(i0>=0 && j0>=0) |
390 |
if(i0>=0 && j0>=0) |
391 |
P(i0,j0) = offset(i0,j0) ; |
391 |
this->P(i0,j0) = this->offset(i0,j0) ; |
392 |
else{ |
392 |
else{ |
393 |
for(int i=0;i<P.rows();++i) |
393 |
for(int i=0;i<this->P.rows();++i) |
394 |
for(int j=0;j<P.cols();++j){ |
394 |
for(int j=0;j<this->P.cols();++j){ |
395 |
P(i,j) = offset(i,j) ; |
395 |
this->P(i,j) = this->offset(i,j) ; |
396 |
} |
396 |
} |
397 |
} |
397 |
} |
398 |
} |
398 |
} |
399 |
|
399 |
|
400 |
++updateN ; |
400 |
++this->updateN ; |
401 |
} |
401 |
} |
402 |
|
402 |
|
403 |
/*! |
403 |
/*! |
Lines 413-419
Link Here
|
413 |
if(!okMax()) |
413 |
if(!okMax()) |
414 |
updateMaxUV() ; |
414 |
updateMaxUV() ; |
415 |
if(upLevel>=0){ |
415 |
if(upLevel>=0){ |
416 |
if(level()<=upLevel){ |
416 |
if(this->level()<=upLevel){ |
417 |
this->updateSurface() ; |
417 |
this->updateSurface() ; |
418 |
} |
418 |
} |
419 |
} |
419 |
} |
Lines 421-429
Link Here
|
421 |
this->updateSurface() ; |
421 |
this->updateSurface() ; |
422 |
} |
422 |
} |
423 |
|
423 |
|
424 |
if(upLevel>level() || upLevel<0){ |
424 |
if(upLevel>this->level() || upLevel<0){ |
425 |
if(nextLevel_) |
425 |
if(this->nextLevel_) |
426 |
((HNurbsSurfaceSP<T,N>*)nextLevel_)->updateLevels(upLevel) ; |
426 |
((HNurbsSurfaceSP<T,N>*)this->nextLevel_)->updateLevels(upLevel) ; |
427 |
} |
427 |
} |
428 |
} |
428 |
} |
429 |
|
429 |
|
Lines 458-467
Link Here
|
458 |
if(!fin.read((char*)&du,sizeof(int))) { delete []type ; return 0 ;} |
458 |
if(!fin.read((char*)&du,sizeof(int))) { delete []type ; return 0 ;} |
459 |
if(!fin.read((char*)&dv,sizeof(int))) { delete []type ; return 0 ;} |
459 |
if(!fin.read((char*)&dv,sizeof(int))) { delete []type ; return 0 ;} |
460 |
|
460 |
|
461 |
resize(nu,nv,du,dv) ; |
461 |
this->resize(nu,nv,du,dv) ; |
462 |
|
462 |
|
463 |
if(!fin.read((char*)U.memory(),sizeof(T)*U.n())) { delete []type ; return 0 ;} |
463 |
if(!fin.read((char*)this->U.memory(),sizeof(T)*this->U.n())) { delete []type ; return 0 ;} |
464 |
if(!fin.read((char*)V.memory(),sizeof(T)*V.n())) { delete []type ; return 0 ;} |
464 |
if(!fin.read((char*)this->V.memory(),sizeof(T)*this->V.n())) { delete []type ; return 0 ;} |
465 |
|
465 |
|
466 |
if(!r1){ |
466 |
if(!r1){ |
467 |
p = new T[3*nu*nv] ; |
467 |
p = new T[3*nu*nv] ; |
Lines 469-478
Link Here
|
469 |
p2 = p ; |
469 |
p2 = p ; |
470 |
for(int i=0;i<nu;i++) |
470 |
for(int i=0;i<nu;i++) |
471 |
for(int j=0;j<nv;j++){ |
471 |
for(int j=0;j<nv;j++){ |
472 |
P(i,j).x() = *(p++) ; |
472 |
this->P(i,j).x() = *(p++) ; |
473 |
P(i,j).y() = *(p++) ; |
473 |
this->P(i,j).y() = *(p++) ; |
474 |
P(i,j).z() = *(p++) ; |
474 |
this->P(i,j).z() = *(p++) ; |
475 |
P(i,j).w() = 1.0 ; |
475 |
this->P(i,j).w() = 1.0 ; |
476 |
} |
476 |
} |
477 |
delete []p2 ; |
477 |
delete []p2 ; |
478 |
} |
478 |
} |
Lines 482-507
Link Here
|
482 |
p2 = p ; |
482 |
p2 = p ; |
483 |
for(int i=0;i<nu;i++) |
483 |
for(int i=0;i<nu;i++) |
484 |
for(int j=0;j<nv;j++){ |
484 |
for(int j=0;j<nv;j++){ |
485 |
P(i,j).x() = *(p++) ; |
485 |
this->P(i,j).x() = *(p++) ; |
486 |
P(i,j).y() = *(p++) ; |
486 |
this->P(i,j).y() = *(p++) ; |
487 |
P(i,j).z() = *(p++) ; |
487 |
this->P(i,j).z() = *(p++) ; |
488 |
P(i,j).w() = *(p++) ; |
488 |
this->P(i,j).w() = *(p++) ; |
489 |
} |
489 |
} |
490 |
delete []p2 ; |
490 |
delete []p2 ; |
491 |
} |
491 |
} |
492 |
offset = P ; |
492 |
this->offset = this->P ; |
493 |
this->updateSurface() ; |
493 |
this->updateSurface() ; |
494 |
} |
494 |
} |
495 |
else { // reading the offset information |
495 |
else { // reading the offset information |
496 |
int ru,rv ; |
496 |
int ru,rv ; |
497 |
if(!fin.read((char*)&ru,sizeof(int))) { delete []type ; return 0 ;} |
497 |
if(!fin.read((char*)&ru,sizeof(int))) { delete []type ; return 0 ;} |
498 |
if(!fin.read((char*)&rv,sizeof(int))) { delete []type ; return 0 ;} |
498 |
if(!fin.read((char*)&rv,sizeof(int))) { delete []type ; return 0 ;} |
499 |
rU.resize(ru) ; |
499 |
this->rU.resize(ru) ; |
500 |
rV.resize(rv) ; |
500 |
this->rV.resize(rv) ; |
501 |
if(rU.n()>0) |
501 |
if(this->rU.n()>0) |
502 |
if(!fin.read((char*)rU.memory(),sizeof(T)*rU.n())) { delete []type ; return 0 ;} |
502 |
if(!fin.read((char*)this->rU.memory(),sizeof(T)*this->rU.n())) { delete []type ; return 0 ;} |
503 |
if(rV.n()>0) |
503 |
if(this->rV.n()>0) |
504 |
if(!fin.read((char*)rV.memory(),sizeof(T)*rV.n())) { delete []type ; return 0 ;} |
504 |
if(!fin.read((char*)this->rV.memory(),sizeof(T)*this->rV.n())) { delete []type ; return 0 ;} |
505 |
|
505 |
|
506 |
if(!fin.read((char*)&nu,sizeof(int))) { delete []type ; return 0 ;} |
506 |
if(!fin.read((char*)&nu,sizeof(int))) { delete []type ; return 0 ;} |
507 |
if(!fin.read((char*)&nv,sizeof(int))) { delete []type ; return 0 ;} |
507 |
if(!fin.read((char*)&nv,sizeof(int))) { delete []type ; return 0 ;} |
Lines 509-524
Link Here
|
509 |
p = new T[4*nu*nv] ; |
509 |
p = new T[4*nu*nv] ; |
510 |
if(!fin.read((char*)p,sizeof(T)*4*nu*nv)) { delete []type ; return 0 ;} |
510 |
if(!fin.read((char*)p,sizeof(T)*4*nu*nv)) { delete []type ; return 0 ;} |
511 |
p2 = p ; |
511 |
p2 = p ; |
512 |
offset.resize(nu,nv) ; |
512 |
this->offset.resize(nu,nv) ; |
513 |
for(int i=0;i<nu;i++) |
513 |
for(int i=0;i<nu;i++) |
514 |
for(int j=0;j<nv;j++){ |
514 |
for(int j=0;j<nv;j++){ |
515 |
offset(i,j).x() = *(p++) ; |
515 |
this->offset(i,j).x() = *(p++) ; |
516 |
offset(i,j).y() = *(p++) ; |
516 |
this->offset(i,j).y() = *(p++) ; |
517 |
offset(i,j).z() = *(p++) ; |
517 |
this->offset(i,j).z() = *(p++) ; |
518 |
offset(i,j).w() = *(p++) ; |
518 |
this->offset(i,j).w() = *(p++) ; |
519 |
} |
519 |
} |
520 |
delete []p2 ; |
520 |
delete []p2 ; |
521 |
--baseUpdateN ; |
521 |
--this->baseUpdateN ; |
522 |
this->updateSurface() ; |
522 |
this->updateSurface() ; |
523 |
} |
523 |
} |
524 |
|
524 |
|
525 |
-- nurbs/matrixRT.cpp.old |
525 |
++ nurbs/matrixRT.cpp |
Lines 51-63
Link Here
|
51 |
// *this = C.translate(x,y,z)*B.rotate(ax,ay,az) ; |
51 |
// *this = C.translate(x,y,z)*B.rotate(ax,ay,az) ; |
52 |
rotate(ax,ay,az) ; |
52 |
rotate(ax,ay,az) ; |
53 |
#ifdef COLUMN_ORDER |
53 |
#ifdef COLUMN_ORDER |
54 |
m[12] = x ; |
54 |
this->m[12] = x ; |
55 |
m[13] = y ; |
55 |
this->m[13] = y ; |
56 |
m[14] = z ; |
56 |
this->m[14] = z ; |
57 |
#else |
57 |
#else |
58 |
m[3] = x ; |
58 |
this->m[3] = x ; |
59 |
m[7] = y ; |
59 |
this->m[7] = y ; |
60 |
m[11] = z ; |
60 |
this->m[11] = z ; |
61 |
#endif |
61 |
#endif |
62 |
} |
62 |
} |
63 |
|
63 |
|
Lines 71-78
Link Here
|
71 |
*/ |
71 |
*/ |
72 |
template <class T> |
72 |
template <class T> |
73 |
MatrixRT<T>::MatrixRT() : Matrix<T>(4,4) { |
73 |
MatrixRT<T>::MatrixRT() : Matrix<T>(4,4) { |
74 |
reset(0) ; |
74 |
this->reset(0) ; |
75 |
diag(1.0) ; |
75 |
this->diag(1.0) ; |
76 |
} |
76 |
} |
77 |
|
77 |
|
78 |
/*! |
78 |
/*! |
Lines 144-176
Link Here
|
144 |
t10 = cos(ax); |
144 |
t10 = cos(ax); |
145 |
t13 = t4*t6; |
145 |
t13 = t4*t6; |
146 |
#ifdef COLUMN_ORDER |
146 |
#ifdef COLUMN_ORDER |
147 |
m[0] = t1*t2; |
147 |
this->m[0] = t1*t2; |
148 |
m[4] = -t4*t2; |
148 |
this->m[4] = -t4*t2; |
149 |
m[8] = t6; |
149 |
this->m[8] = t6; |
150 |
m[12] = 0 ; |
150 |
this->m[12] = 0 ; |
151 |
m[1] = t7*t8+t4*t10; |
151 |
this->m[1] = t7*t8+t4*t10; |
152 |
m[5] = -t13*t8+t1*t10; |
152 |
this->m[5] = -t13*t8+t1*t10; |
153 |
m[9] = -t2*t8; |
153 |
this->m[9] = -t2*t8; |
154 |
m[13] = 0 ; |
154 |
this->m[13] = 0 ; |
155 |
m[2] = -t7*t10+t4*t8; |
155 |
this->m[2] = -t7*t10+t4*t8; |
156 |
m[6] = t13*t10+t1*t8; |
156 |
this->m[6] = t13*t10+t1*t8; |
157 |
m[10] = t2*t10; |
157 |
this->m[10] = t2*t10; |
158 |
m[14] = m[3] = m[7] = m[11] = 0.0 ; |
158 |
this->m[14] = this->m[3] = this->m[7] = this->m[11] = 0.0 ; |
159 |
m[15] = 1.0 ; |
159 |
this->m[15] = 1.0 ; |
160 |
#else |
160 |
#else |
161 |
m[0] = t1*t2; |
161 |
this->m[0] = t1*t2; |
162 |
m[1] = -t4*t2; |
162 |
this->m[1] = -t4*t2; |
163 |
m[2] = t6; |
163 |
this->m[2] = t6; |
164 |
m[3] = 0 ; |
164 |
this->m[3] = 0 ; |
165 |
m[4] = t7*t8+t4*t10; |
165 |
this->m[4] = t7*t8+t4*t10; |
166 |
m[5] = -t13*t8+t1*t10; |
166 |
this->m[5] = -t13*t8+t1*t10; |
167 |
m[6] = -t2*t8; |
167 |
this->m[6] = -t2*t8; |
168 |
m[7] = 0 ; |
168 |
this->m[7] = 0 ; |
169 |
m[8] = -t7*t10+t4*t8; |
169 |
this->m[8] = -t7*t10+t4*t8; |
170 |
m[9] = t13*t10+t1*t8; |
170 |
this->m[9] = t13*t10+t1*t8; |
171 |
m[10] = t2*t10; |
171 |
this->m[10] = t2*t10; |
172 |
m[11] = m[12] = m[13] = m[14] = 0 ; |
172 |
this->m[11] = this->m[12] = this->m[13] = this->m[14] = 0 ; |
173 |
m[15] = 1.0 ; |
173 |
this->m[15] = 1.0 ; |
174 |
#endif |
174 |
#endif |
175 |
return *this ; |
175 |
return *this ; |
176 |
} |
176 |
} |
Lines 203-235
Link Here
|
203 |
t9 = (T)sin((double)ax); |
203 |
t9 = (T)sin((double)ax); |
204 |
t17 = t4*t7; |
204 |
t17 = t4*t7; |
205 |
#ifdef COLUMN_ORDER |
205 |
#ifdef COLUMN_ORDER |
206 |
m[0] = t1*t2; |
206 |
this->m[0] = t1*t2; |
207 |
m[4] = -t4*t5+t8*t9; |
207 |
this->m[4] = -t4*t5+t8*t9; |
208 |
m[8] = t4*t9+t8*t5; |
208 |
this->m[8] = t4*t9+t8*t5; |
209 |
m[12] = 0.0 ; |
209 |
this->m[12] = 0.0 ; |
210 |
m[1] = t4*t2; |
210 |
this->m[1] = t4*t2; |
211 |
m[5] = t1*t5+t17*t9; |
211 |
this->m[5] = t1*t5+t17*t9; |
212 |
m[9] = -t1*t9+t17*t5; |
212 |
this->m[9] = -t1*t9+t17*t5; |
213 |
m[13] = 0.0 ; |
213 |
this->m[13] = 0.0 ; |
214 |
m[2] = -t7; |
214 |
this->m[2] = -t7; |
215 |
m[6] = t2*t9; |
215 |
this->m[6] = t2*t9; |
216 |
m[10] = t2*t5; |
216 |
this->m[10] = t2*t5; |
217 |
m[14] = m[3] = m[7] = m[11] = 0 ; |
217 |
this->m[14] = this->m[3] = this->m[7] = this->m[11] = 0 ; |
218 |
m[15] = 1.0 ; |
218 |
this->m[15] = 1.0 ; |
219 |
#else |
219 |
#else |
220 |
m[0] = t1*t2; |
220 |
this->m[0] = t1*t2; |
221 |
m[1] = -t4*t5+t8*t9; |
221 |
this->m[1] = -t4*t5+t8*t9; |
222 |
m[2] = t4*t9+t8*t5; |
222 |
this->m[2] = t4*t9+t8*t5; |
223 |
m[3] = 0.0 ; |
223 |
this->m[3] = 0.0 ; |
224 |
m[4] = t4*t2; |
224 |
this->m[4] = t4*t2; |
225 |
m[5] = t1*t5+t17*t9; |
225 |
this->m[5] = t1*t5+t17*t9; |
226 |
m[6] = -t1*t9+t17*t5; |
226 |
this->m[6] = -t1*t9+t17*t5; |
227 |
m[7] = 0.0 ; |
227 |
this->m[7] = 0.0 ; |
228 |
m[8] = -t7; |
228 |
this->m[8] = -t7; |
229 |
m[9] = t2*t9; |
229 |
this->m[9] = t2*t9; |
230 |
m[10] = t2*t5; |
230 |
this->m[10] = t2*t5; |
231 |
m[11] = m[12] = m[13] = m[14] = 0 ; |
231 |
this->m[11] = this->m[12] = this->m[13] = this->m[14] = 0 ; |
232 |
m[15] = 1.0 ; |
232 |
this->m[15] = 1.0 ; |
233 |
#endif |
233 |
#endif |
234 |
return *this ; |
234 |
return *this ; |
235 |
} |
235 |
} |
Lines 245-260
Link Here
|
245 |
*/ |
245 |
*/ |
246 |
template <class T> |
246 |
template <class T> |
247 |
MatrixRT<T>& MatrixRT<T>::translate(T x, T y, T z){ |
247 |
MatrixRT<T>& MatrixRT<T>::translate(T x, T y, T z){ |
248 |
reset(0) ; |
248 |
this->reset(0) ; |
249 |
diag(1.0) ; |
249 |
this->diag(1.0) ; |
250 |
#ifdef COLUMN_ORDER |
250 |
#ifdef COLUMN_ORDER |
251 |
m[12] = x ; |
251 |
this->m[12] = x ; |
252 |
m[13] = y ; |
252 |
this->m[13] = y ; |
253 |
m[14] = z ; |
253 |
this->m[14] = z ; |
254 |
#else |
254 |
#else |
255 |
m[3] = x ; |
255 |
this->m[3] = x ; |
256 |
m[7] = y ; |
256 |
this->m[7] = y ; |
257 |
m[11] = z ; |
257 |
this->m[11] = z ; |
258 |
#endif |
258 |
#endif |
259 |
return *this ; |
259 |
return *this ; |
260 |
} |
260 |
} |
Lines 271-281
Link Here
|
271 |
*/ |
271 |
*/ |
272 |
template <class T> |
272 |
template <class T> |
273 |
MatrixRT<T>& MatrixRT<T>::scale(T x, T y, T z){ |
273 |
MatrixRT<T>& MatrixRT<T>::scale(T x, T y, T z){ |
274 |
reset(0) ; |
274 |
this->reset(0) ; |
275 |
m[0] = x ; |
275 |
this->m[0] = x ; |
276 |
m[5] = y ; |
276 |
this->m[5] = y ; |
277 |
m[10] = z ; |
277 |
this->m[10] = z ; |
278 |
m[15] = 1.0 ; |
278 |
this->m[15] = 1.0 ; |
279 |
return *this ; |
279 |
return *this ; |
280 |
} |
280 |
} |
281 |
|
281 |
|
Lines 416-422
Link Here
|
416 |
error.fatal() ; |
416 |
error.fatal() ; |
417 |
} |
417 |
} |
418 |
T *a,*b ; |
418 |
T *a,*b ; |
419 |
a = m-1 ; |
419 |
a = this->m-1 ; |
420 |
b = M[0] - 1 ; |
420 |
b = M[0] - 1 ; |
421 |
for(int i=0;i<16;++i){ |
421 |
for(int i=0;i<16;++i){ |
422 |
*(++a) = *(++b) ; |
422 |
*(++a) = *(++b) ; |
Lines 435-441
Link Here
|
435 |
template <class T> |
435 |
template <class T> |
436 |
MatrixRT<T>& MatrixRT<T>::operator=(const MatrixRT<T>& M) { |
436 |
MatrixRT<T>& MatrixRT<T>::operator=(const MatrixRT<T>& M) { |
437 |
T *a,*b ; |
437 |
T *a,*b ; |
438 |
a = m-1 ; |
438 |
a = this->m-1 ; |
439 |
b = M.m - 1 ; |
439 |
b = M.m - 1 ; |
440 |
for(int i=0;i<16;++i){ |
440 |
for(int i=0;i<16;++i){ |
441 |
*(++a) = *(++b) ; |
441 |
*(++a) = *(++b) ; |
442 |
-- nurbs/nurbs.cpp.old |
442 |
++ nurbs/nurbs.cpp |
Lines 391-399
Link Here
|
391 |
T du,dv ; |
391 |
T du,dv ; |
392 |
// compute a coarse distance for the curve |
392 |
// compute a coarse distance for the curve |
393 |
Point_nD<T,N> a,b,c ; |
393 |
Point_nD<T,N> a,b,c ; |
394 |
a = pointAt(0.0) ; |
394 |
a = this->pointAt(0.0) ; |
395 |
b = pointAt(0.5) ; |
395 |
b = this->pointAt(0.5) ; |
396 |
c = pointAt(1.0) ; |
396 |
c = this->pointAt(1.0) ; |
397 |
|
397 |
|
398 |
T distance = norm(b-a) + norm(c-b) ; |
398 |
T distance = norm(b-a) + norm(c-b) ; |
399 |
|
399 |
|
400 |
-- nurbs/nurbsS.cpp.old |
400 |
++ nurbs/nurbsS.cpp |
Lines 3762-3773
Link Here
|
3762 |
// we use and angle of 36 to view the object |
3762 |
// we use and angle of 36 to view the object |
3763 |
// and position the rest according to this. |
3763 |
// and position the rest according to this. |
3764 |
Point_nD<T,N> minP, maxP ; |
3764 |
Point_nD<T,N> minP, maxP ; |
3765 |
minP.x() = extremum(1,coordX) ; |
3765 |
minP.x() = this->extremum(1,coordX) ; |
3766 |
minP.y() = extremum(1,coordY) ; |
3766 |
minP.y() = this->extremum(1,coordY) ; |
3767 |
minP.z() = extremum(1,coordZ) ; |
3767 |
minP.z() = this->extremum(1,coordZ) ; |
3768 |
maxP.x() = extremum(0,coordX) ; |
3768 |
maxP.x() = this->extremum(0,coordX) ; |
3769 |
maxP.y() = extremum(0,coordY) ; |
3769 |
maxP.y() = this->extremum(0,coordY) ; |
3770 |
maxP.z() = extremum(0,coordZ) ; |
3770 |
maxP.z() = this->extremum(0,coordZ) ; |
3771 |
|
3771 |
|
3772 |
Point_nD<T,N> lookAt ; |
3772 |
Point_nD<T,N> lookAt ; |
3773 |
lookAt.x() = (minP.x()+maxP.x())/2.0 ; |
3773 |
lookAt.x() = (minP.x()+maxP.x())/2.0 ; |
Lines 3860-3871
Link Here
|
3860 |
// we use and angle of 36 to view the object |
3860 |
// we use and angle of 36 to view the object |
3861 |
// and position the rest according to this. |
3861 |
// and position the rest according to this. |
3862 |
Point_nD<T,N> minP, maxP ; |
3862 |
Point_nD<T,N> minP, maxP ; |
3863 |
minP.x() = extremum(1,coordX) ; |
3863 |
minP.x() = this->extremum(1,coordX) ; |
3864 |
minP.y() = extremum(1,coordY) ; |
3864 |
minP.y() = this->extremum(1,coordY) ; |
3865 |
minP.z() = extremum(1,coordZ) ; |
3865 |
minP.z() = this->extremum(1,coordZ) ; |
3866 |
maxP.x() = extremum(0,coordX) ; |
3866 |
maxP.x() = this->extremum(0,coordX) ; |
3867 |
maxP.y() = extremum(0,coordY) ; |
3867 |
maxP.y() = this->extremum(0,coordY) ; |
3868 |
maxP.z() = extremum(0,coordZ) ; |
3868 |
maxP.z() = this->extremum(0,coordZ) ; |
3869 |
|
3869 |
|
3870 |
Point_nD<T,N> lookAt ; |
3870 |
Point_nD<T,N> lookAt ; |
3871 |
lookAt.x() = (minP.x()+maxP.x())/2.0 ; |
3871 |
lookAt.x() = (minP.x()+maxP.x())/2.0 ; |
Lines 4045-4056
Link Here
|
4045 |
} |
4045 |
} |
4046 |
|
4046 |
|
4047 |
Point_nD<T,N> minP, maxP ; |
4047 |
Point_nD<T,N> minP, maxP ; |
4048 |
minP.x() = extremum(1,coordX) ; |
4048 |
minP.x() = this->extremum(1,coordX) ; |
4049 |
minP.y() = extremum(1,coordY) ; |
4049 |
minP.y() = this->extremum(1,coordY) ; |
4050 |
minP.z() = extremum(1,coordZ) ; |
4050 |
minP.z() = this->extremum(1,coordZ) ; |
4051 |
maxP.x() = extremum(0,coordX) ; |
4051 |
maxP.x() = this->extremum(0,coordX) ; |
4052 |
maxP.y() = extremum(0,coordY) ; |
4052 |
maxP.y() = this->extremum(0,coordY) ; |
4053 |
maxP.z() = extremum(0,coordZ) ; |
4053 |
maxP.z() = this->extremum(0,coordZ) ; |
4054 |
|
4054 |
|
4055 |
Point_nD<T,N> lookAt ; |
4055 |
Point_nD<T,N> lookAt ; |
4056 |
lookAt.x() = (minP.x()+maxP.x())/2.0 ; |
4056 |
lookAt.x() = (minP.x()+maxP.x())/2.0 ; |
4057 |
-- nurbs/nurbsS_sp.cpp.old |
4057 |
++ nurbs/nurbsS_sp.cpp |
Lines 43-49
Link Here
|
43 |
*/ |
43 |
*/ |
44 |
template <class T, int N> |
44 |
template <class T, int N> |
45 |
void NurbsSurfaceSP<T,N>::updateMaxU() { |
45 |
void NurbsSurfaceSP<T,N>::updateMaxU() { |
46 |
if(degU>3){ |
46 |
if(this->degU>3){ |
47 |
#ifdef USE_EXCEPTION |
47 |
#ifdef USE_EXCEPTION |
48 |
throw NurbsInputError(); |
48 |
throw NurbsInputError(); |
49 |
#else |
49 |
#else |
Lines 53-64
Link Here
|
53 |
#endif |
53 |
#endif |
54 |
} |
54 |
} |
55 |
else{ |
55 |
else{ |
56 |
maxU.resize(P.rows()) ; |
56 |
maxU.resize(this->P.rows()) ; |
57 |
maxAtU_.resize(P.rows()) ; |
57 |
maxAtU_.resize(this->P.rows()) ; |
58 |
for(int i=0;i<P.rows();++i){ |
58 |
for(int i=0;i<this->P.rows();++i){ |
59 |
if(!maxInfluence(i,U,degU,maxAtU_[i])) |
59 |
if(!maxInfluence(i,this->U,this->degU,maxAtU_[i])) |
60 |
cerr << "Problem in maxInfluence U!\n" ; |
60 |
cerr << "Problem in maxInfluence U!\n" ; |
61 |
maxU[i] = nurbsBasisFun(maxAtU_[i],i,degU,U) ; |
61 |
maxU[i] = nurbsBasisFun(maxAtU_[i],i,this->degU,this->U) ; |
62 |
} |
62 |
} |
63 |
|
63 |
|
64 |
} |
64 |
} |
Lines 78-84
Link Here
|
78 |
*/ |
78 |
*/ |
79 |
template <class T, int N> |
79 |
template <class T, int N> |
80 |
void NurbsSurfaceSP<T,N>::updateMaxV() { |
80 |
void NurbsSurfaceSP<T,N>::updateMaxV() { |
81 |
if(degV>3){ |
81 |
if(this->degV>3){ |
82 |
#ifdef USE_EXCEPTION |
82 |
#ifdef USE_EXCEPTION |
83 |
throw NurbsInputError(); |
83 |
throw NurbsInputError(); |
84 |
#else |
84 |
#else |
Lines 88-99
Link Here
|
88 |
#endif |
88 |
#endif |
89 |
} |
89 |
} |
90 |
else{ |
90 |
else{ |
91 |
maxV.resize(P.cols()) ; |
91 |
maxV.resize(this->P.cols()) ; |
92 |
maxAtV_.resize(P.cols()) ; |
92 |
maxAtV_.resize(this->P.cols()) ; |
93 |
for(int i=0;i<P.cols();++i){ |
93 |
for(int i=0;i<this->P.cols();++i){ |
94 |
if(!maxInfluence(i,V,degV,maxAtV_[i])) |
94 |
if(!maxInfluence(i,this->V,this->degV,maxAtV_[i])) |
95 |
cerr << "Problem in maxInfluence V!\n" ; |
95 |
cerr << "Problem in maxInfluence V!\n" ; |
96 |
maxV[i] = nurbsBasisFun(maxAtV_[i],i,degV,V) ; |
96 |
maxV[i] = nurbsBasisFun(maxAtV_[i],i,this->degV,this->V) ; |
97 |
} |
97 |
} |
98 |
|
98 |
|
99 |
} |
99 |
} |
Lines 124-134
Link Here
|
124 |
NurbsSurfaceSP<T,N> NurbsSurfaceSP<T,N>::generateParallel(T d) const { |
124 |
NurbsSurfaceSP<T,N> NurbsSurfaceSP<T,N>::generateParallel(T d) const { |
125 |
NurbsSurfaceSP<T,N> p(*this) ; |
125 |
NurbsSurfaceSP<T,N> p(*this) ; |
126 |
|
126 |
|
127 |
Vector< Point_nD<T,N> > offset(P.rows()*P.cols()) ; |
127 |
Vector< Point_nD<T,N> > offset(this->P.rows()*this->P.cols()) ; |
128 |
Vector<T> ur(P.rows()*P.cols()) ; |
128 |
Vector<T> ur(this->P.rows()*this->P.cols()) ; |
129 |
Vector<T> vr(P.rows()*P.cols()) ; |
129 |
Vector<T> vr(this->P.rows()*this->P.cols()) ; |
130 |
Vector_INT Du(P.rows()*P.cols()) ; |
130 |
Vector_INT Du(this->P.rows()*this->P.cols()) ; |
131 |
Vector_INT Dv(P.rows()*P.cols()) ; |
131 |
Vector_INT Dv(this->P.rows()*this->P.cols()) ; |
132 |
|
132 |
|
133 |
Du.reset(0) ; |
133 |
Du.reset(0) ; |
134 |
Dv.reset(0) ; |
134 |
Dv.reset(0) ; |
Lines 137-144
Link Here
|
137 |
|
137 |
|
138 |
no = 0 ; |
138 |
no = 0 ; |
139 |
|
139 |
|
140 |
for(i=0;i<P.rows();++i) |
140 |
for(i=0;i<this->P.rows();++i) |
141 |
for(j=0;j<P.cols();++j){ |
141 |
for(j=0;j<this->P.cols();++j){ |
142 |
Point_nD<T,N> norm ; |
142 |
Point_nD<T,N> norm ; |
143 |
norm = normal(maxAtU_[i],maxAtV_[j]) ; |
143 |
norm = normal(maxAtU_[i],maxAtV_[j]) ; |
144 |
if(norm.x() == T(0) && |
144 |
if(norm.x() == T(0) && |
Lines 155-173
Link Here
|
155 |
norm /= T(2) ; |
155 |
norm /= T(2) ; |
156 |
ok = 1 ; |
156 |
ok = 1 ; |
157 |
} |
157 |
} |
158 |
if(i==P.rows()-1 && j==P.cols()-1){ |
158 |
if(i==this->P.rows()-1 && j==this->P.cols()-1){ |
159 |
norm = normal(maxAtU_[i]-delta,maxAtV_[j]) ; |
159 |
norm = normal(maxAtU_[i]-delta,maxAtV_[j]) ; |
160 |
norm += normal(maxAtU_[i],maxAtV_[j]-delta) ; |
160 |
norm += normal(maxAtU_[i],maxAtV_[j]-delta) ; |
161 |
norm /= T(2) ; |
161 |
norm /= T(2) ; |
162 |
ok = 1 ; |
162 |
ok = 1 ; |
163 |
} |
163 |
} |
164 |
if(i==0 && j==P.cols()-1){ |
164 |
if(i==0 && j==this->P.cols()-1){ |
165 |
norm = normal(maxAtU_[i]-delta,maxAtV_[j]) ; |
165 |
norm = normal(maxAtU_[i]-delta,maxAtV_[j]) ; |
166 |
norm += normal(maxAtU_[i],maxAtV_[j]+delta) ; |
166 |
norm += normal(maxAtU_[i],maxAtV_[j]+delta) ; |
167 |
norm /= T(2) ; |
167 |
norm /= T(2) ; |
168 |
ok = 1 ; |
168 |
ok = 1 ; |
169 |
} |
169 |
} |
170 |
if(i==P.rows()-1 && j==0){ |
170 |
if(i==this->P.rows()-1 && j==0){ |
171 |
norm = normal(maxAtU_[i]-delta,maxAtV_[j]) ; |
171 |
norm = normal(maxAtU_[i]-delta,maxAtV_[j]) ; |
172 |
norm += normal(maxAtU_[i],maxAtV_[j]+delta) ; |
172 |
norm += normal(maxAtU_[i],maxAtV_[j]+delta) ; |
173 |
norm /= T(2) ; |
173 |
norm /= T(2) ; |
Lines 178-184
Link Here
|
178 |
while(norm.x() == T(0) && |
178 |
while(norm.x() == T(0) && |
179 |
norm.y() == T(0) && |
179 |
norm.y() == T(0) && |
180 |
norm.z() == T(0)){ |
180 |
norm.z() == T(0)){ |
181 |
if( nt*d >(U[U.n()-1]-U[0])){ |
181 |
if( nt*d >(this->U[this->U.n()-1]-this->U[0])){ |
182 |
#ifdef USE_EXCEPTION |
182 |
#ifdef USE_EXCEPTION |
183 |
throw NurbsComputationError(); |
183 |
throw NurbsComputationError(); |
184 |
#else |
184 |
#else |
Lines 188-199
Link Here
|
188 |
#endif |
188 |
#endif |
189 |
} |
189 |
} |
190 |
T u1,u2,v1,v2 ; |
190 |
T u1,u2,v1,v2 ; |
191 |
if(i==0 || i==P.rows()-1){ |
191 |
if(i==0 || i==this->P.rows()-1){ |
192 |
u1 = u2 = maxAtU_[i] ; |
192 |
u1 = u2 = maxAtU_[i] ; |
193 |
v1 = maxAtV_[j]+ nt*delta ; |
193 |
v1 = maxAtV_[j]+ nt*delta ; |
194 |
v2 = maxAtV_[j]- nt*delta ; |
194 |
v2 = maxAtV_[j]- nt*delta ; |
195 |
if(v1>V[V.n()-1]) v1 = V[V.n()-1] ; |
195 |
if(v1>this->V[this->V.n()-1]) v1 = this->V[this->V.n()-1] ; |
196 |
if(v2<V[0]) v2 = V[0] ; |
196 |
if(v2<this->V[0]) v2 = this->V[0] ; |
197 |
norm = normal(u1,v1); |
197 |
norm = normal(u1,v1); |
198 |
norm += normal(u2,v2) ; |
198 |
norm += normal(u2,v2) ; |
199 |
norm /= 2 ; |
199 |
norm /= 2 ; |
Lines 202-209
Link Here
|
202 |
u1 = maxAtU_[i]- nt*delta ; |
202 |
u1 = maxAtU_[i]- nt*delta ; |
203 |
u2 = maxAtU_[i]+ nt*delta ; |
203 |
u2 = maxAtU_[i]+ nt*delta ; |
204 |
v1 = v2 = maxAtV_[j] ; |
204 |
v1 = v2 = maxAtV_[j] ; |
205 |
if(u1 < U[0]) u1 = U[0] ; |
205 |
if(u1 < this->U[0]) u1 = this->U[0] ; |
206 |
if(u2 > U[U.n()-1]) u2 = U[U.n()-1] ; |
206 |
if(u2 > this->U[this->U.n()-1]) u2 = this->U[this->U.n()-1] ; |
207 |
|
207 |
|
208 |
T u3,v3 ; |
208 |
T u3,v3 ; |
209 |
u3 = maxAtU_[i] ; |
209 |
u3 = maxAtU_[i] ; |
Lines 212-219
Link Here
|
212 |
else |
212 |
else |
213 |
v3 = maxAtV_[j]- nt*delta ; |
213 |
v3 = maxAtV_[j]- nt*delta ; |
214 |
|
214 |
|
215 |
if(v3<V[0]) v3 = V[0] ; |
215 |
if(v3<this->V[0]) v3 = this->V[0] ; |
216 |
if(v3>V[V.n()-1]) v3 = V[V.n()-1] ; |
216 |
if(v3>this->V[this->V.n()-1]) v3 = this->V[this->V.n()-1] ; |
217 |
|
217 |
|
218 |
norm = normal(u1,v1); |
218 |
norm = normal(u1,v1); |
219 |
norm += normal(u2,v2) ; |
219 |
norm += normal(u2,v2) ; |
Lines 263-275
Link Here
|
263 |
|
263 |
|
264 |
int sizeU, sizeV ; |
264 |
int sizeU, sizeV ; |
265 |
|
265 |
|
266 |
sizeU = 2*degU+3 ; |
266 |
sizeU = 2*this->degU+3 ; |
267 |
if(i-degU-1<0) sizeU += i-degU-1 ; |
267 |
if(i-this->degU-1<0) sizeU += i-this->degU-1 ; |
268 |
if(i+degU+1>=P.rows()) sizeU -= i+degU+1-P.rows() ; |
268 |
if(i+this->degU+1>=this->P.rows()) sizeU -= i+this->degU+1-this->P.rows() ; |
269 |
|
269 |
|
270 |
sizeV = 2*degV+3 ; |
270 |
sizeV = 2*this->degV+3 ; |
271 |
if(j-degV-1<0) sizeV += j-degV-1 ; |
271 |
if(j-this->degV-1<0) sizeV += j-this->degV-1 ; |
272 |
if(j+degV+1>=P.cols()) sizeV -= j+degV+1-P.cols() ; |
272 |
if(j+this->degV+1>=this->P.cols()) sizeV -= j+this->degV+1-this->P.cols() ; |
273 |
|
273 |
|
274 |
Vector<T> u(sizeU) ; |
274 |
Vector<T> u(sizeU) ; |
275 |
Vector<T> v(sizeV) ; |
275 |
Vector<T> v(sizeV) ; |
Lines 280-295
Link Here
|
280 |
int n=0; |
280 |
int n=0; |
281 |
int nu = 0 ; |
281 |
int nu = 0 ; |
282 |
int nv = 0 ; |
282 |
int nv = 0 ; |
283 |
for(int k=i-degU-1;k<=i+degU+1;++k){ |
283 |
for(int k=i-this->degU-1;k<=i+this->degU+1;++k){ |
284 |
if(k<0) |
284 |
if(k<0) |
285 |
continue ; |
285 |
continue ; |
286 |
if(k>=P.rows()) |
286 |
if(k>=this->P.rows()) |
287 |
break ; |
287 |
break ; |
288 |
nv = 0 ; |
288 |
nv = 0 ; |
289 |
for(int l=j-degV-1;l<=j+degV+1;++l){ |
289 |
for(int l=j-this->degV-1;l<=j+this->degV+1;++l){ |
290 |
if(l<0) |
290 |
if(l<0) |
291 |
continue ; |
291 |
continue ; |
292 |
if(l>=P.cols()) |
292 |
if(l>=this->P.cols()) |
293 |
break ; |
293 |
break ; |
294 |
if( k == i && j==l){ |
294 |
if( k == i && j==l){ |
295 |
pts[n].x() = a.x() ; |
295 |
pts[n].x() = a.x() ; |
296 |
-- nurbs/nurbsS_sp.h.old |
296 |
++ nurbs/nurbsS_sp.h |
Lines 78-84
Link Here
|
78 |
|
78 |
|
79 |
|
79 |
|
80 |
void modSurfCPby(int i, int j, const HPoint_nD<T,N>& a) //!< Moves a surface point by a value |
80 |
void modSurfCPby(int i, int j, const HPoint_nD<T,N>& a) //!< Moves a surface point by a value |
81 |
{ P(i,j) += a / (maxU[i]*maxV[j]) ; } |
81 |
{ this->P(i,j) += a / (maxU[i]*maxV[j]) ; } |
82 |
void modSurfCP(int i, int j, const HPoint_nD<T,N>& a) //!< Moves a surface point to a value |
82 |
void modSurfCP(int i, int j, const HPoint_nD<T,N>& a) //!< Moves a surface point to a value |
83 |
{ modSurfCPby(i,j,a-surfP(i,j)) ; } |
83 |
{ modSurfCPby(i,j,a-surfP(i,j)) ; } |
84 |
|
84 |
|
85 |
-- nurbs/nurbsSub.cpp.old |
85 |
++ nurbs/nurbsSub.cpp |
Lines 904-910
Link Here
|
904 |
|
904 |
|
905 |
/* Allocate storage for the grid of points generated */ |
905 |
/* Allocate storage for the grid of points generated */ |
906 |
|
906 |
|
907 |
CHECK( pts = new (SurfSample<T>*)[Granularity+1]); |
907 |
CHECK( pts = new SurfSample<T>*[Granularity+1]); |
908 |
CHECK( pts[0] = new SurfSample<T>[(Granularity+1)*(Granularity+1)]); |
908 |
CHECK( pts[0] = new SurfSample<T>[(Granularity+1)*(Granularity+1)]); |
909 |
|
909 |
|
910 |
for (i = 1; i <= Granularity; i++) |
910 |
for (i = 1; i <= Granularity; i++) |
Lines 983-989
Link Here
|
983 |
|
983 |
|
984 |
if (! *alpha) /* Must allocate alpha */ |
984 |
if (! *alpha) /* Must allocate alpha */ |
985 |
{ |
985 |
{ |
986 |
CHECK( *alpha = new (T*)[k+1]); |
986 |
CHECK( *alpha = new T*[k+1]); |
987 |
for (i = 0; i <= k; i++) |
987 |
for (i = 0; i <= k; i++) |
988 |
CHECK( (*alpha)[i] = new T[(m + n + 1)]); |
988 |
CHECK( (*alpha)[i] = new T[(m + n + 1)]); |
989 |
} |
989 |
} |
990 |
-- nurbs/nurbs_sp.cpp.old |
990 |
++ nurbs/nurbs_sp.cpp |
Lines 41-47
Link Here
|
41 |
*/ |
41 |
*/ |
42 |
template <class T, int N> |
42 |
template <class T, int N> |
43 |
void NurbsCurveSP<T,N>::updateMaxU() { |
43 |
void NurbsCurveSP<T,N>::updateMaxU() { |
44 |
if(deg_>3){ |
44 |
if(this->deg_>3){ |
45 |
#ifdef USE_EXCEPTION |
45 |
#ifdef USE_EXCEPTION |
46 |
throw NurbsInputError(); |
46 |
throw NurbsInputError(); |
47 |
#else |
47 |
#else |
Lines 51-60
Link Here
|
51 |
#endif |
51 |
#endif |
52 |
} |
52 |
} |
53 |
else{ |
53 |
else{ |
54 |
maxU.resize(P.n()) ; |
54 |
maxU.resize(this->P.n()) ; |
55 |
maxAt_.resize(P.n()) ; |
55 |
maxAt_.resize(this->P.n()) ; |
56 |
for(int i=0;i<P.n();++i){ |
56 |
for(int i=0;i<this->P.n();++i){ |
57 |
if(!maxInfluence(i,U,deg_,maxAt_[i])) |
57 |
if(!maxInfluence(i,this->U,this->deg_,maxAt_[i])) |
58 |
cerr << "Problem in maxInfluence U!\n" ; |
58 |
cerr << "Problem in maxInfluence U!\n" ; |
59 |
if(i>0) |
59 |
if(i>0) |
60 |
if(maxAt_[i]<maxAt_[i-1]){ |
60 |
if(maxAt_[i]<maxAt_[i-1]){ |
Lines 69-75
Link Here
|
69 |
error.fatal() ; |
69 |
error.fatal() ; |
70 |
#endif |
70 |
#endif |
71 |
} |
71 |
} |
72 |
maxU[i] = basisFun(maxAt_[i],i,deg_) ; |
72 |
maxU[i] = basisFun(maxAt_[i],i,this->deg_) ; |
73 |
} |
73 |
} |
74 |
|
74 |
|
75 |
} |
75 |
} |
Lines 96-109
Link Here
|
96 |
*/ |
96 |
*/ |
97 |
template <class T, int N> |
97 |
template <class T, int N> |
98 |
void NurbsCurveSP<T,N>::modOnlySurfCPby(int i, const HPoint_nD<T,N>& a){ |
98 |
void NurbsCurveSP<T,N>::modOnlySurfCPby(int i, const HPoint_nD<T,N>& a){ |
99 |
Vector<T> u(2*deg_+3) ; |
99 |
Vector<T> u(2*this->deg_+3) ; |
100 |
Vector< Point_nD<T,N> > pts(2*deg_+3) ; |
100 |
Vector< Point_nD<T,N> > pts(2*this->deg_+3) ; |
101 |
|
101 |
|
102 |
int n=0; |
102 |
int n=0; |
103 |
for(int j=i-deg_-1;j<=i+deg_+1;++j){ |
103 |
for(int j=i-this->deg_-1;j<=i+this->deg_+1;++j){ |
104 |
if(j<0) |
104 |
if(j<0) |
105 |
continue ; |
105 |
continue ; |
106 |
if(j>=P.n()) |
106 |
if(j>=this->P.n()) |
107 |
break ; |
107 |
break ; |
108 |
u[n] = maxAt_[j] ; |
108 |
u[n] = maxAt_[j] ; |
109 |
if( j == i){ |
109 |
if( j == i){ |
110 |
-- nurbs/nurbs_sp.h.old |
110 |
++ nurbs/nurbs_sp.h |
Lines 72-78
Link Here
|
72 |
int read(ifstream &fin) ; |
72 |
int read(ifstream &fin) ; |
73 |
|
73 |
|
74 |
void modSurfCPby(int i, const HPoint_nD<T,N>& a) |
74 |
void modSurfCPby(int i, const HPoint_nD<T,N>& a) |
75 |
{ P[i] += a / maxU[i] ; } |
75 |
{ this->P[i] += a / maxU[i] ; } |
76 |
void modSurfCP(int i, const HPoint_nD<T,N>& a) |
76 |
void modSurfCP(int i, const HPoint_nD<T,N>& a) |
77 |
{ modSurfCPby(i,a-surfP(i)) ; } |
77 |
{ modSurfCPby(i,a-surfP(i)) ; } |
78 |
|
78 |
|