00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 OSG_BEGIN_NAMESPACE
00040
00041
00042
00043
00044
00053 #if defined(__hpux)
00054 template <class ValueTypeT>
00055 const UInt32 VecStorage1<ValueTypeT>::_uiSize;
00056 #endif
00057
00058
00059 template <class ValueTypeT> inline
00060 VecStorage1<ValueTypeT>::VecStorage1(void)
00061 {
00062 for(UInt32 i = 0; i < _uiSize; i++)
00063 {
00064 _values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00065 }
00066 }
00067
00068
00069 template <class ValueTypeT> inline
00070 VecStorage1<ValueTypeT>::~VecStorage1(void)
00071 {
00072 }
00073
00074
00075 template <class ValueTypeT> inline
00076 void VecStorage1<ValueTypeT>::setValues(const ValueTypeT rVal1)
00077 {
00078 _values[0] = rVal1;
00079 }
00080
00081
00082 template <class ValueTypeT> inline
00083 void VecStorage1<ValueTypeT>::getSeparateValues(ValueTypeT &rVal1) const
00084 {
00085 rVal1 = _values[0];
00086 }
00087
00088
00089 template <class ValueTypeT> inline
00090 ValueTypeT VecStorage1<ValueTypeT>::x(void) const
00091 {
00092 return _values[0];
00093 }
00094
00095
00096
00097
00098
00099
00100
00109 #if defined(__hpux)
00110 template <class ValueTypeT>
00111 const UInt32 VecStorage2<ValueTypeT>::_uiSize;
00112 #endif
00113
00114
00115 template <class ValueTypeT> inline
00116 VecStorage2<ValueTypeT>::VecStorage2(void)
00117 {
00118 for(UInt32 i = 0; i < _uiSize; i++)
00119 {
00120 _values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00121 }
00122 }
00123
00124
00125 template <class ValueTypeT> inline
00126 VecStorage2<ValueTypeT>::~VecStorage2(void)
00127 {
00128 }
00129
00130
00131 template <class ValueTypeT> inline
00132 void VecStorage2<ValueTypeT>::setValues(const ValueTypeT rVal1,
00133 const ValueTypeT rVal2)
00134 {
00135 _values[0] = rVal1;
00136 _values[1] = rVal2;
00137 }
00138
00139
00140 template <class ValueTypeT> inline
00141 void VecStorage2<ValueTypeT>::getSeparateValues(ValueTypeT &rVal1,
00142 ValueTypeT &rVal2) const
00143 {
00144 rVal1 = _values[0];
00145 rVal2 = _values[1];
00146 }
00147
00148
00149 template <class ValueTypeT> inline
00150 ValueTypeT VecStorage2<ValueTypeT>::x(void) const
00151 {
00152 return _values[0];
00153 }
00154
00155
00156 template <class ValueTypeT> inline
00157 ValueTypeT VecStorage2<ValueTypeT>::y(void) const
00158 {
00159 return _values[1];
00160 }
00161
00162
00163
00164
00165
00166
00167
00168
00177 #if defined(__hpux)
00178 template <class ValueTypeT>
00179 const UInt32 VecStorage3<ValueTypeT>::_uiSize;
00180 #endif
00181
00182
00183 template <class ValueTypeT> inline
00184 VecStorage3<ValueTypeT>::VecStorage3(void)
00185 {
00186 for(UInt32 i = 0; i < _uiSize; i++)
00187 {
00188 _values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00189 }
00190 }
00191
00192
00193 template <class ValueTypeT> inline
00194 VecStorage3<ValueTypeT>::~VecStorage3(void)
00195 {
00196 }
00197
00198
00199 template <class ValueTypeT> inline
00200 void VecStorage3<ValueTypeT>::setValues(const ValueTypeT rVal1,
00201 const ValueTypeT rVal2,
00202 const ValueTypeT rVal3)
00203 {
00204 _values[0] = rVal1;
00205 _values[1] = rVal2;
00206 _values[2] = rVal3;
00207 }
00208
00209
00210 template <class ValueTypeT> inline
00211 void VecStorage3<ValueTypeT>::getSeparateValues(ValueTypeT &rVal1,
00212 ValueTypeT &rVal2,
00213 ValueTypeT &rVal3) const
00214 {
00215 rVal1 = _values[0];
00216 rVal2 = _values[1];
00217 rVal3 = _values[2];
00218 }
00219
00220
00221 template <class ValueTypeT> inline
00222 ValueTypeT VecStorage3<ValueTypeT>::x(void) const
00223 {
00224 return _values[0];
00225 }
00226
00227
00228 template <class ValueTypeT> inline
00229 ValueTypeT VecStorage3<ValueTypeT>::y(void) const
00230 {
00231 return _values[1];
00232 }
00233
00234
00235 template <class ValueTypeT> inline
00236 ValueTypeT VecStorage3<ValueTypeT>::z(void) const
00237 {
00238 return _values[2];
00239 }
00240
00241
00242
00243
00244
00245
00246
00247
00256 #if defined(__hpux)
00257 template <class ValueTypeT> inline
00258 const UInt32 VecStorage4<ValueTypeT>::_uiSize;
00259 #endif
00260
00261
00262 template <class ValueTypeT> inline
00263 VecStorage4<ValueTypeT>::VecStorage4(void)
00264 {
00265 for(UInt32 i = 0; i < _uiSize; i++)
00266 {
00267 _values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00268 }
00269 }
00270
00271
00272 template <class ValueTypeT> inline
00273 VecStorage4<ValueTypeT>::~VecStorage4(void)
00274 {
00275 }
00276
00277
00278 template <class ValueTypeT> inline
00279 void VecStorage4<ValueTypeT>::setValues(const ValueTypeT rVal1,
00280 const ValueTypeT rVal2,
00281 const ValueTypeT rVal3,
00282 const ValueTypeT rVal4)
00283 {
00284 _values[0] = rVal1;
00285 _values[1] = rVal2;
00286 _values[2] = rVal3;
00287 _values[3] = rVal4;
00288 }
00289
00290
00291 template <class ValueTypeT> inline
00292 void VecStorage4<ValueTypeT>::getSeparateValues(ValueTypeT &rVal1,
00293 ValueTypeT &rVal2,
00294 ValueTypeT &rVal3,
00295 ValueTypeT &rVal4) const
00296 {
00297 rVal1 = _values[0];
00298 rVal2 = _values[1];
00299 rVal3 = _values[2];
00300 rVal4 = _values[3];
00301 }
00302
00303
00304 template <class ValueTypeT> inline
00305 ValueTypeT VecStorage4<ValueTypeT>::x(void) const
00306 {
00307 return _values[0];
00308 }
00309
00310
00311 template <class ValueTypeT> inline
00312 ValueTypeT VecStorage4<ValueTypeT>::y(void) const
00313 {
00314 return _values[1];
00315 }
00316
00317
00318 template <class ValueTypeT> inline
00319 ValueTypeT VecStorage4<ValueTypeT>::z(void) const
00320 {
00321 return _values[2];
00322 }
00323
00324
00325 template <class ValueTypeT> inline
00326 ValueTypeT VecStorage4<ValueTypeT>::w(void) const
00327 {
00328 return _values[3];
00329 }
00330
00331
00332
00333
00334
00335
00336
00353 #ifndef darwinXXX
00354 template <class ValueTypeT,
00355 class StorageInterfaceT>
00356 const PointInterface<ValueTypeT, StorageInterfaceT>
00357 PointInterface<ValueTypeT, StorageInterfaceT>::Null;
00358 #endif
00359
00360
00361 template <class ValueTypeT,
00362 class StorageInterfaceT> inline
00363 PointInterface<ValueTypeT, StorageInterfaceT>::PointInterface(void) :
00364 Inherited()
00365 {
00366 }
00367
00373 template <class ValueTypeT,
00374 class StorageInterfaceT> inline
00375 PointInterface<ValueTypeT,
00376 StorageInterfaceT>::PointInterface(const ValueTypeT *pVals) :
00377 Inherited()
00378 {
00379 if(pVals == NULL)
00380 {
00381 for(UInt32 i = 0; i < Self::_uiSize; i++)
00382 {
00383 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00384 }
00385 }
00386 else
00387 {
00388 for(UInt32 i = 0; i < Self::_uiSize; i++)
00389 {
00390 Self::_values[i] = pVals[i];
00391 }
00392 }
00393 }
00394
00400 template <class ValueTypeT,
00401 class StorageInterfaceT> inline
00402 PointInterface<ValueTypeT,
00403 StorageInterfaceT>::PointInterface(ValueTypeT *pVals) :
00404 Inherited()
00405 {
00406 if(pVals == NULL)
00407 {
00408 for(UInt32 i = 0; i < Self::_uiSize; i++)
00409 {
00410 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00411 }
00412 }
00413 else
00414 {
00415 for(UInt32 i = 0; i < Self::_uiSize; i++)
00416 {
00417 Self::_values[i] = pVals[i];
00418 }
00419 }
00420 }
00421
00422 template <class ValueTypeT,
00423 class StorageInterfaceT>
00424 template <class ValueType2T,
00425 class StorageInterface2T> inline
00426 PointInterface<ValueTypeT, StorageInterfaceT>::PointInterface(
00427 const PointInterface<ValueType2T, StorageInterface2T> &vec)
00428 {
00429 typedef PointInterface<ValueType2T, StorageInterface2T> VectorT;
00430
00431 if(Self::_uiSize <= VectorT::_uiSize)
00432 {
00433 for(UInt32 i = 0; i < Self::_uiSize; i++)
00434 {
00435 Self::_values[i] = vec.getValues()[i];
00436 }
00437 }
00438 else
00439 {
00440 UInt32 i;
00441 for(i = 0; i < VectorT::_uiSize; i++)
00442 {
00443 Self::_values[i] = vec.getValues()[i];
00444 }
00445 for(i = VectorT::_uiSize; i < Self::_uiSize; i++)
00446 {
00447 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00448 }
00449 }
00450 }
00451
00452 template <class ValueTypeT,
00453 class StorageInterfaceT>
00454 template <class ValueType2T,
00455 class StorageInterface2T> inline
00456 PointInterface<ValueTypeT, StorageInterfaceT>::PointInterface(
00457 const VectorInterface<ValueType2T, StorageInterface2T> &vec)
00458 {
00459 typedef VectorInterface<ValueType2T, StorageInterface2T> VectorT;
00460
00461 if(Self::_uiSize <= VectorT::_uiSize)
00462 {
00463 for(UInt32 i = 0; i < Self::_uiSize; i++)
00464 {
00465 Self::_values[i] = vec.getValues()[i];
00466 }
00467 }
00468 else
00469 {
00470 UInt32 i;
00471 for(i = 0; i < VectorT::_uiSize; i++)
00472 {
00473 Self::_values[i] = vec.getValues()[i];
00474 }
00475 for(i = VectorT::_uiSize; i < Self::_uiSize; i++)
00476 {
00477 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00478 }
00479 }
00480 }
00481
00482
00483 template <class ValueTypeT,
00484 class StorageInterfaceT> inline
00485 PointInterface<ValueTypeT, StorageInterfaceT>::PointInterface(
00486 const PointInterface &source) :
00487
00488 Inherited()
00489 {
00490 for(UInt32 i = 0; i < Self::_uiSize; i++)
00491 {
00492 Self::_values[i] = source._values[i];
00493 }
00494 }
00495
00496
00497
00498 template <class ValueTypeT,
00499 class StorageInterfaceT> inline
00500 PointInterface<ValueTypeT, StorageInterfaceT>::PointInterface(
00501 const ValueTypeT rVal1)
00502 {
00503 UInt32 i;
00504
00505 Self::_values[0] = rVal1;
00506
00507 for(i = 1; i < Self::_uiSize; i++)
00508 {
00509 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00510 }
00511 }
00512
00513
00514
00515 #ifdef __sgi
00516 #pragma set woff 1209
00517 #endif
00518
00520
00521 template <class ValueTypeT,
00522 class StorageInterfaceT> inline
00523 PointInterface<ValueTypeT,
00524 StorageInterfaceT>::PointInterface(const ValueTypeT rVal1,
00525 const ValueTypeT rVal2) :
00526 Inherited()
00527 {
00528 Self::_values[0] = rVal1;
00529
00530 if(Self::_uiSize == 2)
00531 {
00532 Self::_values[1] = rVal2;
00533 }
00534 else if(Self::_uiSize >= 3)
00535 {
00536 Self::_values[1] = rVal2;
00537
00538 for(UInt32 i = 2; i < Self::_uiSize; i++)
00539 {
00540 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00541 }
00542 }
00543 }
00544
00545 #ifdef __sgi
00546 #pragma reset woff 1209
00547
00548 #pragma set woff 1209
00549 #endif
00550
00552
00553 template <class ValueTypeT,
00554 class StorageInterfaceT> inline
00555 PointInterface<ValueTypeT,
00556 StorageInterfaceT>::PointInterface(const ValueTypeT rVal1,
00557 const ValueTypeT rVal2,
00558 const ValueTypeT rVal3) :
00559 Inherited()
00560 {
00561 Self::_values[0] = rVal1;
00562
00563 if(Self::_uiSize == 2)
00564 {
00565 Self::_values[1] = rVal2;
00566 }
00567 else if(Self::_uiSize == 3)
00568 {
00569 Self::_values[1] = rVal2;
00570 Self::_values[2] = rVal3;
00571 }
00572 else if(Self::_uiSize >= 4)
00573 {
00574 Self::_values[1] = rVal2;
00575 Self::_values[2] = rVal3;
00576
00577 for(UInt32 i = 3; i < Self::_uiSize; i++)
00578 {
00579 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00580 }
00581 }
00582 }
00583
00584 #ifdef __sgi
00585 #pragma reset woff 1209
00586
00587 #pragma set woff 1209
00588 #endif
00589
00591
00592 template <class ValueTypeT,
00593 class StorageInterfaceT> inline
00594 PointInterface<ValueTypeT,
00595 StorageInterfaceT>::PointInterface(const ValueTypeT rVal1,
00596 const ValueTypeT rVal2,
00597 const ValueTypeT rVal3,
00598 const ValueTypeT rVal4) :
00599 Inherited()
00600 {
00601 Self::_values[0] = rVal1;
00602
00603 if(Self::_uiSize == 2)
00604 {
00605 Self::_values[1] = rVal2;
00606 }
00607 else if(Self::_uiSize == 3)
00608 {
00609 Self::_values[1] = rVal2;
00610 Self::_values[2] = rVal3;
00611 }
00612 else if(Self::_uiSize == 4)
00613 {
00614 Self::_values[1] = rVal2;
00615 Self::_values[2] = rVal3;
00616 Self::_values[3] = rVal4;
00617 }
00618 else if(Self::_uiSize >= 5)
00619 {
00620 Self::_values[1] = rVal2;
00621 Self::_values[2] = rVal3;
00622 Self::_values[3] = rVal4;
00623
00624 for(UInt32 i = 4; i < Self::_uiSize; i++)
00625 {
00626 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00627 }
00628 }
00629 }
00630
00631 #ifdef __sgi
00632 #pragma reset woff 1209
00633 #endif
00634
00635
00636
00637
00638 template <class ValueTypeT,
00639 class StorageInterfaceT> inline
00640 PointInterface<ValueTypeT, StorageInterfaceT>::~PointInterface(void)
00641 {
00642 }
00643
00644
00645
00646
00647 template <class ValueTypeT,
00648 class StorageInterfaceT> inline
00649 void PointInterface<ValueTypeT, StorageInterfaceT>::setNull(void)
00650 {
00651 for(UInt32 i = 0; i < Self::_uiSize; i++)
00652 {
00653 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00654 }
00655 }
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669 template <class ValueTypeT,
00670 class StorageInterfaceT> inline
00671 void PointInterface<ValueTypeT,
00672 StorageInterfaceT>::setValue(const PointInterface &vec)
00673 {
00674 for(UInt32 i = 0; i < Self::_uiSize; i++)
00675 {
00676 Self::_values[i] = vec._values[i];
00677 }
00678 }
00679
00680 template <class ValueTypeT,
00681 class StorageInterfaceT>
00682 template <class ValueType2T,
00683 class StorageInterface2T> inline
00684 void PointInterface<ValueTypeT,
00685 StorageInterfaceT>::setValue(
00686 const PointInterface<ValueType2T,
00687 StorageInterface2T> &vec)
00688 {
00689 typedef PointInterface<ValueType2T, StorageInterface2T> VectorT;
00690
00691 static const UInt32 nElementsToCopy =
00692 Self::_uiSize < VectorT::_uiSize ? Self::_uiSize : VectorT::_uiSize;
00693
00694 for(UInt32 i = 0; i < nElementsToCopy; ++i)
00695 {
00696 Self::_values[i] = vec.getValues()[i];
00697 }
00698 }
00699
00700 template <class ValueTypeT,
00701 class StorageInterfaceT> inline
00702 void PointInterface<ValueTypeT,
00703 StorageInterfaceT>::setValue(const ValueTypeT *pVals)
00704 {
00705 for(UInt32 i = 0; i < Self::_uiSize; i++)
00706 {
00707 Self::_values[i] = pVals[i];
00708 }
00709 }
00710
00712
00713 template <class ValueTypeT,
00714 class StorageInterfaceT> inline
00715 void PointInterface<ValueTypeT,
00716 StorageInterfaceT>::setValue(ValueTypeT *pVals)
00717 {
00718 setValue(static_cast<const ValueTypeT *>(pVals));
00719 }
00720
00725 template <class ValueTypeT,
00726 class StorageInterfaceT> inline
00727 void PointInterface<ValueTypeT,
00728 StorageInterfaceT>::setValueFromCString(
00729 const Char8 *szString)
00730 {
00731 UInt32 i;
00732 UInt32 numOfToken = Self::_uiSize;
00733
00734 Char8 *c = const_cast<Char8 *>(szString);
00735 Char8 *tokenC = 0;
00736
00737 Char8 token[256];
00738
00739 if(szString == NULL || (*szString) == '\0')
00740 {
00741 for(i = 0; i < Self::_uiSize; i++)
00742 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement();
00743
00744 return;
00745 }
00746
00747 for (i = 0; i < numOfToken; c++)
00748 {
00749 switch (*c)
00750 {
00751 case '\0':
00752 if(tokenC)
00753 {
00754 *tokenC = 0;
00755 Self::_values[i++] =
00756 TypeTraits<ValueTypeT>::getFromCString(token);
00757 }
00758
00759 while (i < numOfToken)
00760 {
00761 Self::_values[i++] =
00762 TypeTraits<ValueTypeT>::getZeroElement();
00763 }
00764 break;
00765
00766 case ' ' :
00767 case '\t':
00768 case '\n':
00769 case ',':
00770 if(tokenC)
00771 {
00772 *tokenC = 0;
00773 Self::_values[i++] =
00774 TypeTraits<ValueTypeT>::getFromCString(token);
00775 tokenC = 0;
00776 }
00777 break;
00778 default:
00779 if(!tokenC)
00780 {
00781 tokenC = token;
00782 }
00783 *tokenC++ = *c;
00784 break;
00785 }
00786 }
00787 }
00788
00793 template <class ValueTypeT,
00794 class StorageInterfaceT> inline
00795 void PointInterface<ValueTypeT,
00796 StorageInterfaceT>::setValueFromCString(Char8 *szString)
00797 {
00798 setValueFromCString(static_cast<const Char8 *>(szString));
00799 }
00800
00801 #ifndef OSG_DISABLE_DEPRECATED
00802 template <class ValueTypeT,
00803 class StorageInterfaceT> inline
00804 void PointInterface<ValueTypeT,
00805 StorageInterfaceT>::setValue(const Char8 *szString)
00806 {
00807 setValueFromCString(szString);
00808 }
00809
00810 template <class ValueTypeT,
00811 class StorageInterfaceT> inline
00812 void PointInterface<ValueTypeT,
00813 StorageInterfaceT>::setValue(Char8 *szString)
00814 {
00815 setValueFromCString(szString);
00816 }
00817 #endif
00818
00819
00820
00821
00823
00824 template <class ValueTypeT,
00825 class StorageInterfaceT> inline
00826 ValueTypeT *PointInterface<ValueTypeT,
00827 StorageInterfaceT>::getValues(void)
00828 {
00829 return Self::_values;
00830 }
00831
00833
00834 template <class ValueTypeT,
00835 class StorageInterfaceT> inline
00836 const ValueTypeT *PointInterface<ValueTypeT,
00837 StorageInterfaceT>::getValues(void) const
00838 {
00839 return Self::_values;
00840 }
00841
00842
00843
00844
00846
00847 template <class ValueTypeT,
00848 class StorageInterfaceT> inline
00849 bool PointInterface<ValueTypeT,
00850 StorageInterfaceT>::isZero(void) const
00851 {
00852 bool returnValue = true;
00853
00854 for(UInt32 i = 0; i < Self::_uiSize; i++)
00855 {
00856 returnValue &= ((Self::_values[i] <= Eps) &&
00857 (Self::_values[i] >= -Eps));
00858 }
00859
00860 return returnValue;
00861 }
00862
00864
00865 template <class ValueTypeT,
00866 class StorageInterfaceT> inline
00867 void PointInterface<ValueTypeT, StorageInterfaceT>::negate(void)
00868 {
00869 for(UInt32 i = 0; i < Self::_uiSize; i++)
00870 {
00871 Self::_values[i] = -Self::_values[i];
00872 }
00873 }
00874
00876
00877 template <class ValueTypeT,
00878 class StorageInterfaceT> inline
00879 bool PointInterface<ValueTypeT, StorageInterfaceT>::equals(
00880 const PointInterface &vec,
00881 const ValueTypeT tolerance) const
00882 {
00883 bool returnValue = true;
00884
00885 for(UInt32 i = 0; i < Self::_uiSize; i++)
00886 {
00887 returnValue &=
00888 ( (Self::_values[i] - vec ._values[i] <= tolerance) &&
00889 (vec ._values[i] - Self::_values[i] <= tolerance));
00890 }
00891
00892 return returnValue;
00893 }
00894
00896
00897 template <class ValueTypeT,
00898 class StorageInterfaceT> inline
00899 typename PointInterface<ValueTypeT,
00900 StorageInterfaceT>::VecInterface &
00901 PointInterface<ValueTypeT,
00902 StorageInterfaceT>::subZero(void)
00903 {
00904 return *(static_cast<VecInterface *>(this));
00905 }
00906
00908
00909 template <class ValueTypeT,
00910 class StorageInterfaceT> inline
00911 const typename PointInterface<ValueTypeT,
00912 StorageInterfaceT>::VecInterface &
00913 PointInterface<ValueTypeT,
00914 StorageInterfaceT>::subZero(void) const
00915 {
00916 return *(static_cast<const VecInterface *>(this));
00917 }
00918
00919
00921
00922 template <class ValueTypeT,
00923 class StorageInterfaceT> inline
00924 typename PointInterface<ValueTypeT,
00925 StorageInterfaceT>::RealReturnType
00926 PointInterface<ValueTypeT, StorageInterfaceT>::dist(const PointInterface &vec)
00927 const
00928 {
00929 return osgSqrt(dist2(vec));
00930 }
00931
00933
00934 template <class ValueTypeT,
00935 class StorageInterfaceT> inline
00936 typename PointInterface<ValueTypeT,
00937 StorageInterfaceT>::RealReturnType
00938 PointInterface<ValueTypeT, StorageInterfaceT>::dist2(const PointInterface &vec)
00939 const
00940 {
00941 RealReturnType returnValue = 0;
00942 RealReturnType tmp;
00943
00944 for(UInt32 i = 0; i < Self::_uiSize; i++)
00945 {
00946 tmp = Self::_values[i] - vec._values[i];
00947
00948 returnValue += tmp * tmp;
00949 }
00950
00951 return returnValue;
00952 }
00953
00955
00956 template <class ValueTypeT,
00957 class StorageInterfaceT> inline
00958 typename PointInterface<ValueTypeT,
00959 StorageInterfaceT>::RealReturnType
00960 PointInterface<ValueTypeT, StorageInterfaceT>::maxValue(void)
00961 const
00962 {
00963 RealReturnType returnValue = TypeTraits<RealReturnType>::getMin();
00964
00965 for(UInt32 i = 0; i < Self::_uiSize; i++)
00966 {
00967 if(Self::_values[i] > returnValue)
00968 returnValue = Self::_values[i];
00969 }
00970
00971 return returnValue;
00972 }
00973
00974
00975
00976
00978
00979 template <class ValueTypeT,
00980 class StorageInterfaceT> inline
00981 void PointInterface<ValueTypeT,
00982 StorageInterfaceT>::operator *=(const ValueTypeT val)
00983 {
00984 for(UInt32 i = 0; i < Self::_uiSize; i++)
00985 {
00986 Self::_values[i] *= val;
00987 }
00988 }
00989
00991
00992 template <class ValueTypeT,
00993 class StorageInterfaceT> inline
00994 void PointInterface<ValueTypeT,
00995 StorageInterfaceT>::operator /=(const ValueTypeT val)
00996 {
00997 for(UInt32 i = 0; i < Self::_uiSize; i++)
00998 {
00999 Self::_values[i] /= val;
01000 }
01001 }
01002
01003
01005
01006 template <class ValueTypeT,
01007 class StorageInterfaceT> inline
01008 typename PointInterface<ValueTypeT, StorageInterfaceT>::VecInterface
01009 PointInterface<ValueTypeT, StorageInterfaceT>::operator -(
01010 const PointInterface &vec) const
01011 {
01012 VecInterface returnValue(*this);
01013
01014 for(UInt32 i = 0; i < Self::_uiSize; i++)
01015 {
01016 returnValue[i] -= vec[i];
01017 }
01018
01019 return returnValue;
01020 }
01021
01023
01024 template <class ValueTypeT,
01025 class StorageInterfaceT> inline
01026 PointInterface<ValueTypeT, StorageInterfaceT>
01027 PointInterface<ValueTypeT, StorageInterfaceT>::operator + (
01028 const VecInterface &vec) const
01029 {
01030 PointInterface<ValueTypeT, StorageInterfaceT> returnValue;
01031
01032 for(UInt32 i = 0; i < StorageInterfaceT::_uiSize; i++)
01033 {
01034 returnValue[i] = Self::_values[i] + vec[i];
01035 }
01036
01037 return returnValue;
01038 }
01039
01041
01042 template <class ValueTypeT,
01043 class StorageInterfaceT> inline
01044 PointInterface<ValueTypeT, StorageInterfaceT>
01045 PointInterface<ValueTypeT, StorageInterfaceT>::operator - (
01046 const VecInterface &vec) const
01047 {
01048 PointInterface<ValueTypeT, StorageInterfaceT> returnValue;
01049
01050 for(UInt32 i = 0; i < StorageInterfaceT::_uiSize; i++)
01051 {
01052 returnValue[i] = Self::_values[i] - vec[i];
01053 }
01054
01055 return returnValue;
01056 }
01057
01059
01060 template <class ValueTypeT,
01061 class StorageInterfaceT> inline
01062 PointInterface <ValueTypeT, StorageInterfaceT>
01063 PointInterface<ValueTypeT, StorageInterfaceT>::operator * (
01064 const ValueTypeT rVal) const
01065 {
01066 PointInterface<ValueTypeT, StorageInterfaceT> returnValue;
01067
01068 for(UInt32 i = 0; i < StorageInterfaceT::_uiSize; i++)
01069 {
01070 returnValue[i] = Self::_values[i] * rVal;
01071 }
01072
01073 return returnValue;
01074 }
01075
01077
01078 template <class ValueTypeT,
01079 class StorageInterfaceT> inline
01080 PointInterface<ValueTypeT, StorageInterfaceT>
01081 PointInterface<ValueTypeT, StorageInterfaceT>::operator -(void)
01082 {
01083 PointInterface<ValueTypeT, StorageInterfaceT> returnValue;
01084
01085 for(UInt32 i = 0; i < Self::_uiSize; i++)
01086 {
01087 returnValue._values[i] = - Self::_values[i];
01088 }
01089
01090 return returnValue;
01091 }
01092
01094
01095 template <class ValueTypeT,
01096 class StorageInterfaceT> inline
01097 void PointInterface<ValueTypeT, StorageInterfaceT>::operator +=(
01098 const VecInterface &vec)
01099 {
01100 for(UInt32 i = 0; i < Self::_uiSize; i++)
01101 {
01102 Self::_values[i] += vec._values[i];
01103 }
01104 }
01105
01107
01108 template <class ValueTypeT,
01109 class StorageInterfaceT> inline
01110 void PointInterface<ValueTypeT, StorageInterfaceT>::operator -=(
01111 const VecInterface &vec)
01112 {
01113 for(UInt32 i = 0; i < Self::_uiSize; i++)
01114 {
01115 Self::_values[i] -= vec._values[i];
01116 }
01117 }
01118
01119
01120
01121
01122 template <class ValueTypeT,
01123 class StorageInterfaceT> inline
01124 ValueTypeT &PointInterface<ValueTypeT,
01125 StorageInterfaceT>::operator[](const UInt32 uiVal)
01126 {
01127 return Self::_values[uiVal];
01128 }
01129
01130 template <class ValueTypeT,
01131 class StorageInterfaceT> inline
01132 const ValueTypeT &
01133 PointInterface<ValueTypeT,
01134 StorageInterfaceT>::operator[](const UInt32 uiVal) const
01135 {
01136 return Self::_values[uiVal];
01137 }
01138
01139 #if 0
01140 template <class ValueTypeT,
01141 class StorageInterfaceT> inline
01142 PointInterface<ValueTypeT, StorageInterfaceT>::operator
01143 ValueTypeT *(void)
01144 {
01145 return Self::_values;
01146 }
01147
01148 template <class ValueTypeT,
01149 class StorageInterfaceT> inline
01150 PointInterface<ValueTypeT, StorageInterfaceT>::operator
01151 const ValueTypeT *(void)
01152 {
01153 return Self::_values;
01154 }
01155 #endif
01156
01157
01158
01159
01160 template <class ValueTypeT,
01161 class StorageInterfaceT> inline
01162 PointInterface<ValueTypeT, StorageInterfaceT> &
01163 PointInterface<ValueTypeT, StorageInterfaceT>::operator =(
01164 const PointInterface &source)
01165 {
01166 if(this == &source)
01167 return *this;
01168
01169 for(UInt32 i = 0; i < Self::_uiSize; i++)
01170 {
01171 Self::_values[i] = source._values[i];
01172 }
01173
01174 return *this;
01175 }
01176
01177 template <class ValueTypeT,
01178 class StorageInterfaceT> inline
01179 PointInterface<ValueTypeT, StorageInterfaceT> &
01180 PointInterface<ValueTypeT,
01181 StorageInterfaceT>::operator =(const VecInterface &source)
01182 {
01183 PointInterface<ValueTypeT,
01184 StorageInterfaceT>::error_cannot_assign_vector;
01185
01186 return *this;
01187 }
01188
01189
01190
01191
01192 template <class ValueTypeT,
01193 class StorageInterfaceT> inline
01194 bool PointInterface<ValueTypeT, StorageInterfaceT>::operator < (
01195 const PointInterface &other) const
01196 {
01197 bool ret = false;
01198
01199 for(UInt32 i = 0; i < Self::_uiSize; i++)
01200 {
01201 if(Self::_values[i] > other._values[i])
01202 {
01203 break;
01204 }
01205
01206 if(Self::_values[i] < other._values[i])
01207 {
01208 ret = true;
01209 break;
01210 }
01211 }
01212
01213 return ret;
01214 }
01215
01217
01218 template <class ValueTypeT,
01219 class StorageInterfaceT> inline
01220 bool PointInterface<ValueTypeT, StorageInterfaceT>::operator == (
01221 const PointInterface &other) const
01222 {
01223 return Self::equals(other, ValueTypeT(Eps));
01224 }
01225
01227
01228 template <class ValueTypeT,
01229 class StorageInterfaceT> inline
01230 bool PointInterface<ValueTypeT, StorageInterfaceT>::operator != (
01231 const PointInterface &other) const
01232 {
01233 return ! (*this == other);
01234 }
01235
01236
01237
01238
01240
01241 template <class ValueTypeT,
01242 class StorageInterfaceT> inline
01243 PointInterface<ValueTypeT, StorageInterfaceT>
01244 operator *(const ValueTypeT val,
01245 const PointInterface<ValueTypeT,
01246 StorageInterfaceT> &vec)
01247 {
01248 PointInterface<ValueTypeT, StorageInterfaceT> returnValue;
01249
01250 for(UInt32 i = 0; i < StorageInterfaceT::_uiSize; i++)
01251 {
01252 returnValue[i] = vec[i] * val;
01253 }
01254
01255 return returnValue;
01256 }
01257
01259
01260 template <class ValueTypeT,
01261 class StorageInterfaceT> inline
01262 std::ostream &operator <<( std::ostream &os,
01263 const PointInterface<ValueTypeT,
01264 StorageInterfaceT> &obj)
01265 {
01266 for(UInt32 i = 0; i < StorageInterfaceT::_uiSize; i++)
01267 {
01268 os << obj[i];
01269
01270 if(i != StorageInterfaceT::_uiSize - 1)
01271 os << ", ";
01272 }
01273
01274 return os;
01275 }
01276
01277
01279
01280
01281 template <class StorageInterfaceT> inline
01282 std::ostream &operator <<( std::ostream &os,
01283 const PointInterface<UInt8,
01284 StorageInterfaceT> &obj)
01285 {
01286 for(UInt32 i = 0; i < StorageInterfaceT::_uiSize; i++)
01287 {
01288 os << static_cast<UInt16>(obj[i]);
01289
01290 if(i != StorageInterfaceT::_uiSize - 1)
01291 os << ", ";
01292 }
01293
01294 return os;
01295 }
01296
01297 template <class StorageInterfaceT> inline
01298 std::ostream &operator <<( std::ostream &os,
01299 const PointInterface<Int8,
01300 StorageInterfaceT> &obj)
01301 {
01302 for(UInt32 i = 0; i < StorageInterfaceT::_uiSize; i++)
01303 {
01304 os << static_cast<Int16>(obj[i]);
01305
01306 if(i != StorageInterfaceT::_uiSize - 1)
01307 os << ", ";
01308 }
01309
01310 return os;
01311 }
01312
01313
01314
01315
01316
01317
01330 template <class ValueTypeT,
01331 class StorageInterfaceT>
01332 const VectorInterface<ValueTypeT, StorageInterfaceT>
01333 VectorInterface<ValueTypeT, StorageInterfaceT>::Null;
01334
01335
01336
01337
01338 template <class ValueTypeT,
01339 class StorageInterfaceT> inline
01340 VectorInterface<ValueTypeT, StorageInterfaceT>::VectorInterface(void) :
01341 Inherited()
01342 {
01343 for(UInt32 i = 0; i < Self::_uiSize; i++)
01344 {
01345 Self::_values[i] = TypeTraits<ValueTypeT>::getZeroElement();
01346 }
01347 }
01348
01349
01355 template <class ValueTypeT,
01356 class StorageInterfaceT> inline
01357 VectorInterface<ValueTypeT,
01358 StorageInterfaceT>::VectorInterface(const ValueTypeT *pVals) :
01359 Inherited(pVals)
01360 {
01361 }
01362
01368 template <class ValueTypeT,
01369 class StorageInterfaceT> inline
01370 VectorInterface<ValueTypeT,
01371 StorageInterfaceT>::VectorInterface(ValueTypeT *pVals) :
01372 Inherited(pVals)
01373 {
01374 }
01375
01376 template <class ValueTypeT,
01377 class StorageInterfaceT>
01378 template <class ValueType2T,
01379 class StorageInterface2T> inline
01380 VectorInterface<ValueTypeT, StorageInterfaceT>::VectorInterface(
01381 const PointInterface<ValueType2T, StorageInterface2T> &vec) :
01382
01383 Inherited(vec)
01384 {
01385 }
01386
01387 template <class ValueTypeT,
01388 class StorageInterfaceT>
01389 template <class ValueType2T,
01390 class StorageInterface2T> inline
01391 VectorInterface<ValueTypeT, StorageInterfaceT>::VectorInterface(
01392 const VectorInterface<ValueType2T, StorageInterface2T> &vec) :
01393
01394 Inherited(vec)
01395 {
01396 }
01397
01398
01399 template <class ValueTypeT,
01400 class StorageInterfaceT> inline
01401 VectorInterface<ValueTypeT, StorageInterfaceT>::VectorInterface(
01402 const VectorInterface &source) :
01403
01404 Inherited(source)
01405 {
01406 }
01407
01408 template <class ValueTypeT,
01409 class StorageInterfaceT> inline
01410 VectorInterface<ValueTypeT,
01411 StorageInterfaceT>::