示例#1
0
static anbool create_quad(hpquads_t* me, anbool count_uses) {
	quadbuilder_t* qb;

	qb = quadbuilder_init();

	qb->starxyz = me->stars;
	qb->starinds = me->inds;
	qb->Nstars = me->Nstars;
	qb->dimquads = me->dimquads;
	qb->quadd2_low = me->quad_dist2_lower;
	qb->quadd2_high = me->quad_dist2_upper;
	qb->check_scale_low = TRUE;
	qb->check_scale_high = TRUE;
	qb->check_AB_stars = check_midpoint;
	qb->check_AB_stars_token = me;
	qb->check_full_quad = check_full_quad;
	qb->check_full_quad_token = me;
	qb->add_quad = add_quad;
	qb->add_quad_token = me;
	me->quad_created = FALSE;
	me->count_uses = count_uses;
	quadbuilder_create(qb);
	quadbuilder_free(qb);

	return me->quad_created;
}
示例#2
0
int allquads_create_quads(allquads_t* aq) {
	quadbuilder_t* qb;
	int i, N;
	double* xyz;

	qb = quadbuilder_init();

	qb->quadd2_high = aq->quad_d2_upper;
	qb->quadd2_low  = aq->quad_d2_lower;
	qb->check_scale_high = aq->use_d2_upper;
	qb->check_scale_low  = aq->use_d2_lower;

	qb->dimquads = aq->dimquads;
	qb->add_quad = add_quad;
	qb->add_quad_token = aq;

	N = startree_N(aq->starkd);

	if (!qb->check_scale_high) {
		int* inds;
		inds = malloc(N * sizeof(int));
		for (i=0; i<N; i++)
			inds[i] = i;
		xyz = malloc(3 * N * sizeof(double));
		kdtree_copy_data_double(aq->starkd->tree, 0, N, xyz);

		qb->starxyz = xyz;
		qb->starinds = inds;
		qb->Nstars = N;

		quadbuilder_create(qb);

		free(xyz);
		free(inds);
	} else {
		int nq;
		int lastgrass = 0;

		/*
		 xyz = malloc(3 * N * sizeof(double));
		 kdtree_copy_data_double(aq->starkd->tree, 0, N, xyz);
		 */

		// star A = i
		nq = aq->quads->numquads;
		for (i=0; i<N; i++) {
			double xyzA[3];
			int* inds;
			int NR;

			int grass = (i*80 / N);
			if (grass != lastgrass) {
				printf(".");
				fflush(stdout);
				lastgrass = grass;
			}

			startree_get(aq->starkd, i, xyzA);

			startree_search_for(aq->starkd, xyzA, aq->quad_d2_upper,
								&xyz, NULL, &inds, &NR);

			/*
			 startree_search_for(aq->starkd, xyzA, aq->quad_d2_upper,
			 NULL, NULL, &inds, &NR);
			 */

			logverb("Star %i of %i: found %i stars in range\n", i+1, N, NR);
			aq->starA = i;
			qb->starxyz = xyz;
			qb->starinds = inds;
			qb->Nstars = NR;
			qb->check_AB_stars = check_AB;
			qb->check_AB_stars_token = aq;
			//qb->check_full_quad = check_full_quad;
			//qb->check_full_quad_token = aq;

			quadbuilder_create(qb);

			logverb("Star %i of %i: wrote %i quads for this star, total %i so far.\n", i+1, N, aq->quads->numquads - nq, aq->quads->numquads);
			free(inds);
			free(xyz);
		}
		//
		//free(xyz);

		printf("\n");
	}

	quadbuilder_free(qb);
	return 0;
}