void KMCentersTree::skeleton_tree(const Ints &p_id,
  KMPoint *bb_lo,KMPoint *bb_hi) {
  //TODO: where do get n from ?
  IMP_INTERNAL_CHECK(data_points_ != nullptr,
                     "Points must be supplied to construct tree.");
  if (p_id.size() == 0) {
    for (int i = 0; i < data_points_->get_number_of_points(); i++)
      p_id_.push_back(i);
  }
  else {
    for (int i = 0; i < data_points_->get_number_of_points(); i++)
      p_id_.push_back(p_id[i]);
  }
  if (bb_lo == nullptr || bb_hi == nullptr) {
    bnd_box_ = bounding_rectangle(0,data_points_->get_number_of_points()-1);;
  }
  // if points are provided, use it
  if (bb_lo != nullptr) {
    copy_point(bb_lo,bnd_box_->get_point(0));
  }
  if (bb_hi != nullptr) {
    copy_point(bb_hi,bnd_box_->get_point(1));
  }
  root_ = nullptr;
}
示例#2
0
void swap_point(point a, point b) {
	point c;		/* temporary point */

	copy_point(a, c);
	copy_point(b, a);
	copy_point(c, b);
}
示例#3
0
文件: mwt.c 项目: armenr/algorist
void sort_and_remove_duplicates(point in[], int *n) {
  int i;                  /* counter */
  int oldn;               /* number of points before deletion */
  int hole;               /* index marked for potential deletion */

	qsort(in, *n, sizeof(point), leftlower);
  oldn = *n;
	hole = 1;
	
  for(i = 1; i <oldn; i++) 
		if((in[hole-1][X] == in[i][X]) && (in[hole-1][Y] == in[i][Y])) 
      (*n)--;
    else {
      copy_point(in[i], in[hole]);
      hole++;
    }
    
  copy_point(in[oldn-1], in[hole]);
}
示例#4
0
date_HEAP_SORT::date_HEAP_SORT(point **l,int taille,int d)
{
	date_list = l;
	max_nb = taille;
	dimension_split = d;
	tas = new point*[max_nb];
	tas_add();
	tas_sort();
	copy_point(l);
}
示例#5
0
文件: KMData.cpp 项目: newtonjoo/imp
void copy_points(KMPointArray *from, KMPointArray *to) {
  if (from == nullptr) {
    return;
  }
  for (unsigned int i = 0; i < from->size(); i++) {
    KMPoint *p = new KMPoint();
    copy_point((*from)[i], p);
    to->push_back(p);
  }
}
示例#6
0
文件: mwt.c 项目: armenr/algorist
void convex_hull(point in[], int n, polygon *hull) {
	int i;			/* input counter */
	int top;		/* current hull size */
	bool smaller_angle();
	
	if(n <= 3) { 		/* all points on hull! */
		for (i=0; i<n; i++)
      copy_point(in[i], hull->p[i]);
		hull->n = n;
		return;
	}

	sort_and_remove_duplicates(in, &n);
	copy_point(in[0], first_point);
	qsort(&in[1], n-1, sizeof(point), smaller_angle);
	copy_point(first_point, hull->p[0]);
	copy_point(in[1], hull->p[1]);
	copy_point(first_point, in[n]);	/* sentinel to avoid special case */
	top = 1;
	i = 2;

	while(i <= n) 
		if(!ccw(hull->p[top-1], hull->p[top], in[i])) 
			top--;	/* top not on hull */
		else {
			top++;
    	copy_point(in[i], hull->p[top]);
			i++;
		}

	hull->n = top;
}
示例#7
0
void segment_to_points(const segment s, point p1, point p2) {
	copy_point(s.p1, p1);
	copy_point(s.p2, p2);
}
示例#8
0
void points_to_segment(const point a, const point b, segment *s) {
	copy_point(a, s->p1);
	copy_point(b, s->p2);
}