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 #ifndef PLIB_BARRAY_HPOINT_SOURCE
00027 #define PLIB_BARRAY_HPOINT_SOURCE
00028
00029 #include "barray.cpp"
00030
00031 namespace PLib {
00032
00033 template <>
00034 void resizeBasicArray(BasicArray<HPoint_nD<float,2> >& a, int nsize){
00035 resizeBasicArrayHPoint(a,nsize) ;
00036 }
00037
00038 template <>
00039 void resizeBasicArray<HPoint_nD<float,3> >(BasicArray<HPoint_nD<float,3> >& a, int nsize){
00040 resizeBasicArrayHPoint(a,nsize) ;
00041 }
00042
00043 template <>
00044 void resizeBasicArray(BasicArray<HPoint_nD<double,2> >& a, int nsize){
00045 resizeBasicArrayHPoint(a,nsize) ;
00046 }
00047
00048 template <>
00049 void resizeBasicArray(BasicArray<HPoint_nD<double,3> >& a, int nsize){
00050 resizeBasicArrayHPoint(a,nsize) ;
00051 }
00052
00053 template <class T, const int D>
00054 void resizeBasicArrayHPoint(BasicArray<HPoint_nD<T,D> >& a, int nsize){
00055 int k=0;
00056
00057 if ( nsize == a.rsize ){
00058 a.sze = nsize ;
00059 return;
00060 }
00061
00062 if(a.sze>nsize){
00063 a.sze = nsize ;
00064 return ;
00065 }
00066
00067 if((a.sze<nsize) && (nsize<a.rsize)){
00068 memset((void*)(a.x[k].data),0,(nsize-a.sze)*(D+1)*sizeof(T)) ;
00069 a.sze = nsize ;
00070 return ;
00071 }
00072
00073 HPoint_nD<T,D> *xn ;
00074
00075 xn = new NoInitHPoint_nD<T,D>[nsize] ;
00076 T* data = new T[nsize*(D+1)];
00077
00078 for(k=nsize-1;k>=0;--k){
00079 xn[k].data = data+ k*(D+1);
00080 }
00081
00082 xn[0].created = 1;
00083
00084 if ( a.x ) {
00085
00086 memcpy((void*)(xn[0].data),(void*)(a.x[0].data),a.sze*(D+1)*sizeof(T)) ;
00087 if(a.sze<nsize)
00088 memset((void*)(xn[a.sze].data),0,(D+1)*sizeof(T)*(nsize-a.sze)) ;
00089 if(a.sze>0 && a.destruct){
00090 delete []a.x;
00091 }
00092 }
00093 else
00094 memset((void*)(xn[0].data),0,nsize*(D+1)*sizeof(T)) ;
00095
00096 a.rsize = nsize;
00097 a.sze = a.rsize ;
00098 a.x = xn;
00099 a.destruct = 1 ;
00100
00101 a.wdth = a.rsize + 1;
00102 }
00103
00104
00105
00106 #ifdef NO_IMPLICIT_TEMPLATES
00107
00108 template class BasicArray<HPoint3Df> ;
00109 template void resizeBasicArrayHPoint(BasicArray<HPoint3Df>&,int) ;
00110 template int operator!=(const BasicArray<HPoint3Df>&,const BasicArray<HPoint3Df>&);
00111 template int operator==(const BasicArray<HPoint3Df>&,const BasicArray<HPoint3Df>&);
00112 template istream& operator>>(istream& is, BasicArray<HPoint3Df>& ary);
00113 template ostream& operator<<(ostream& os, const BasicArray<HPoint3Df>& ary);
00114
00115 template class BasicArray<HPoint3Dd> ;
00116 template void resizeBasicArrayHPoint(BasicArray<HPoint3Dd>&,int) ;
00117 template int operator!=(const BasicArray<HPoint3Dd>&,const BasicArray<HPoint3Dd>&);
00118 template int operator==(const BasicArray<HPoint3Dd>&,const BasicArray<HPoint3Dd>&);
00119 template istream& operator>>(istream& is, BasicArray<HPoint3Dd>& ary);
00120 template ostream& operator<<(ostream& os, const BasicArray<HPoint3Dd>& ary);
00121
00122 template class BasicArray<HPoint2Df> ;
00123 template void resizeBasicArrayHPoint(BasicArray<HPoint2Df>&,int) ;
00124 template int operator!=(const BasicArray<HPoint2Df>&,const BasicArray<HPoint2Df>&);
00125 template int operator==(const BasicArray<HPoint2Df>&,const BasicArray<HPoint2Df>&);
00126 template istream& operator>>(istream& is, BasicArray<HPoint2Df>& ary);
00127 template ostream& operator<<(ostream& os, const BasicArray<HPoint2Df>& ary);
00128
00129 template class BasicArray<HPoint2Dd> ;
00130 template void resizeBasicArrayHPoint(BasicArray<HPoint2Dd>&,int) ;
00131 template int operator!=(const BasicArray<HPoint2Dd>&,const BasicArray<HPoint2Dd>&);
00132 template int operator==(const BasicArray<HPoint2Dd>&,const BasicArray<HPoint2Dd>&);
00133 template istream& operator>>(istream& is, BasicArray<HPoint2Dd>& ary);
00134 template ostream& operator<<(ostream& os, const BasicArray<HPoint2Dd>& ary);
00135
00136 #endif
00137
00138 }
00139
00140 #endif // PLIB_BARRAY_HPOINT_SOURCE
00141