Пример #1
0
void distance (int np         /* number of points */, 
	       float **points /* point coordinates [np][3] */,
	       float* dist    /* distance */, 
	       float* v       /* slowness squared */,
	       int* in                    /* in/front/out flag */, 
	       int n3,int n2,int n1       /* dimensions */,
	       float o3,float o2,float o1 /* origin */,
	       float d3,float d2,float d1 /* sampling */,
	       int order                  /* accuracy order (1,2,3) */)
/*< Run fast marching eikonal solver >*/
{
    float d[3], o[3], *p;
    int n[3], npoints, i;
    
    n[0] = n1; o[0] = o1; d[0] = d1;
    n[1] = n2; o[1] = o2; d[1] = d2;
    n[2] = n3; o[2] = o3; d[2] = d3;

    sf_pqueue_start();
    sf_neighbors_init (in, d, n, order, dist);

    for (npoints =  sf_neighbors_distance (np, v, points, d, o);
	 npoints > 0;
	 npoints -= sf_neighbours(i)) {
	/* Pick smallest value in the NarrowBand
	   mark as good, decrease points_left */

	/* sf_warning("npoints=%d",npoints); */

	p = sf_pqueue_extract();

	if (p == NULL) {
	    sf_warning("%s: heap exausted!",__FILE__);
	    break;
	}

	i = p - dist;

	in[i] = SF_IN;
    }
}
Пример #2
0
void timecont (float* time                /* time */, 
	       float* t0                  /* time at the surface */,
	       float* v                   /* slowness */, 
	       int* in                    /* in/front/out flag */, 
	       int   n3,  int n2,  int n1 /* dimensions */,
	       float d3,float d2,float d1 /* sampling */,
	       int order                  /* accuracy order (1,2,3) */,
	       bool forwd                 /* forward or backward */)
/*< Run fast marching eikonal solver >*/
{
    float d[3], *p;
    int n[3], npoints, i, maxband;

    maxband = 0;
    if (n1 > 1) maxband += 2*n2*n3;
    if (n2 > 1) maxband += 2*n1*n3;
    if (n3 > 1) maxband += 2*n1*n2;

    sf_pqueue_init (10*maxband);
    
    n[0] = n1; d[0] = d1;
    n[1] = n2; d[1] = d2;
    n[2] = n3; d[2] = d3;

    sf_pqueue_start();
    sf_neighbors_init (in, d, n, order, time);

    if (forwd) {
	for (npoints =  sf_neighbors_surface (v, t0, true);
	     npoints > 0;
	     npoints -= sf_neighbours(i)) {
	    /* Pick smallest value in the NarrowBand
	       mark as good, decrease points_left */
	
	    p = sf_pqueue_extract();

	    if (p == NULL) {
		sf_warning("%s: heap exausted!",__FILE__);
		break;
	    }
	
	    i = p - time;

	    in[i] = SF_IN;
	}
    } else {
	for (npoints =  sf_neighbors_surface (v, t0, false);
	     npoints > 0;
	     npoints -= sf_neighbours2(i)) {
	    /* Pick largest value in the NarrowBand
	       mark as good, decrease points_left */
	
	    p = sf_pqueue_extract2();

	    if (p == NULL) {
		sf_warning("%s: heap exausted!",__FILE__);
		break;
	    }
	
	    i = p - time;

	    in[i] = SF_IN;
	}
    }
    
    sf_pqueue_close();
}