Main Page   Class Hierarchy   Compound List   File List   Compound Members  

barray_hpoint.cpp

00001 /*=============================================================================
00002         File: barray_hpoint.cpp
00003      Purpose:       
00004     Revision: $Id: barray_hpoint.cpp,v 1.5 2003/01/13 19:41:15 philosophil Exp $
00005   Created by: Philippe Lavoie          (3 Oct, 1996)
00006  Modified by: 
00007 
00008  Copyright notice:
00009           Copyright (C) 1996-1998 Philippe Lavoie
00010  
00011           This library is free software; you can redistribute it and/or
00012           modify it under the terms of the GNU Library General Public
00013           License as published by the Free Software Foundation; either
00014           version 2 of the License, or (at your option) any later version.
00015  
00016           This library is distributed in the hope that it will be useful,
00017           but WITHOUT ANY WARRANTY; without even the implied warranty of
00018           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019           Library General Public License for more details.
00020  
00021           You should have received a copy of the GNU Library General Public
00022           License along with this library; if not, write to the Free
00023           Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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;                     // nothing to do
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   // The first data object will be responsible to delete the data array.
00082   xn[0].created = 1; 
00083 
00084   if ( a.x )    {
00085       // copy the old data
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 

Generated on Tue Jun 24 13:26:54 2003 for NURBS++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002