www.pudn.com > AdRBF.rar > PointSet.h


#ifndef POINTSET_H  
#define POINTSET_H  
 
#include  
#include  
 
class PointSet{ 
 
public: 
  float (*_point)[3]; 
  float (*_normal)[3]; 
  float *_value; 
  int _pointN; 
   
public: 
  PointSet(){ 
    _pointN = 0; 
    _point = NULL; 
    _normal = NULL; 
    _value = NULL; 
  } 
   
  PointSet(int N, float (*point)[3], float (*normal)[3]){ 
    setPointSize(N); 
    for(int i=0; i _point[j][i]) 
          min[i] = _point[j][i]; 
        if(max[i] < _point[j][i]) 
          max[i] = _point[j][i]; 
      } 
      float s = max[i]-min[i]; 
      float m = 0.5f*(max[i]+min[i]); 
      max[i] = m + 0.5f*rate*s; 
      min[i] = m - 0.5f*rate*s; 
    } 
  } 
   
  void getBound(float min[3], float max[3], int start, int end){ 
    for(int i=0; i<3; i++){ 
      max[i] = min[i] = _point[start][i]; 
      for(int j=start+1; j _point[j][i]) 
          min[i] = _point[j][i]; 
        if(max[i] < _point[j][i]) 
          max[i] = _point[j][i]; 
      } 
      float s = max[i]-min[i]; 
      float m = 0.5f*(max[i]+min[i]); 
      max[i] = m + 0.5f*s; 
      min[i] = m - 0.5f*s; 
    } 
  } 
   
  //Index "end" is not taken int account 
  void centroid(float c[3], int start, int end){ 
    c[0] = c[1] = c[2] = 0; 
    for(int i=start; i