⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 amdb_support.cc

📁 Libgist is an implementation of the Generalized Search Tree, a template index structure that makes i
💻 CC
📖 第 1 页 / 共 3 页
字号:
	return notok;    double scales[displayDim];    scales[0] = ((double) width) / (max[0] - min[0]);    scales[1] = ((double) height) / (max[1] - min[1]);    // we pass in the colors for each of the preds so now we just do it     // once.    pcursor.reset();    int x, y, x1, x2, y1, y2;    //    for (int i = 0; i < pcursor.numElems(); i++) {	    while (pcursor.getNext(key, keyLen, keyLevel, keyColor) != eEOF) {	// if on leaf, plot a point ...	if (keyLevel == 1) {	    rt_point pt(dim, (const double *) key);	    x = (int) floor((pt.co(0) - min[0]) * scales[0]);	    y = height - (int) floor((pt.co(1) - min[1]) * scales[1]);		    env->CallVoidMethod(graphicsContext, setColorId, colors[keyColor]);	    env->CallVoidMethod(graphicsContext, drawRectId, x, y, 1, 1);	} else {	    rt_rect r(dim, (const double *) key);	    x1 = (int) floor((r.lo(0) - min[0]) * scales[0]);	    x2 = (int) floor((r.hi(0) - min[0]) * scales[0]);	    y1 = (int) floor((r.lo(1) - min[1]) * scales[1]);	    y2 = (int) floor((r.hi(1) - min[1]) * scales[1]);	    	    env->CallVoidMethod(graphicsContext, setColorId, colors[keyColor]);	    y1 = height - y1;	    y2 = height - y2;	    	    env->CallVoidMethod(graphicsContext, drawRectId, x1, y2, x2-x1, 		abs(y2-y1));	}    }    return(RCOK);}rc_tamdb_support::display_sp_point_preds(    JNIEnv* env,    jint    width,    jint    height,    jobject graphicsContext, // in: Java class: java.awt.Graphics    jobject colors[], // in: array of java.awt.Color objects    gist_disppredcursor_t& pcursor) // in: predicates to display{    if (pcursor.numPreds() == 0) return RCOK; // nothing to display ...    initIds(env, graphicsContext);    char tempData[gist_p::max_tup_sz];    void *key = (void *) tempData;    int keyLen;    int keyLevel;    int keyColor;    // get initial key so we can determine the number of dims ...    pcursor.getNext(key, keyLen, keyLevel, keyColor);    // we can only display 2-dim data    int dim;    if (keyLevel == 1)	dim = rt_point::size2dim(keyLen);    else 	dim = rt_bounding_sphere::size2dim(keyLen);    //     if (dim != displayDim) {// 	cout << "display() displayDim != dim: " << displayDim // 	     << " " << dim << endl;//         return RCOK;//     }    // find min/max along each dimension    double min[displayDim];    double max[displayDim];        int j;        double tmin, tmax;    // initialize the ranges along each dimension ...    if (keyLevel == 1) {	rt_point pt(dim, (const double *) key);	for (j = 0; j < displayDim; j++) {	    min[j] = pt.co(j);	    max[j] = pt.co(j);	}    } else {	rt_bounding_sphere s(dim, (const double *) key);	for (j = 0; j < displayDim; j++) {	    tmin = s.center.co(j) - s.radius();	    tmax = s.center.co(j) + s.radius();	    min[j] = tmin;	    max[j] = tmax;	}    }    while (pcursor.getNext(key, keyLen, keyLevel, keyColor) != eEOF) {	// If level is one then its a leaf ... 	if (keyLevel == 1) {	    rt_point pt(dim, (const double *) key);	    for (j = 0; j < displayDim; j++) {		if (min[j] > pt.co(j)) min[j] = pt.co(j);		if (max[j] < pt.co(j)) max[j] = pt.co(j);	    }	} else {	    rt_bounding_sphere s(dim, (const double *) key);	    for (j = 0; j < displayDim; j++) {		tmin = s.center.co(j) - s.radius();		tmax = s.center.co(j) + s.radius();		if (min[j] > tmin) min[j] = tmin;		if (max[j] < tmax) max[j] = tmax;	    }	}    }     int notok = drawScales(&width, &height, min[0], max[0], min[1], max[1],	env, graphicsContext);        if (notok)	return notok;    double scales[displayDim];    scales[0] = ((double) width) / (max[0] - min[0]);    scales[1] = ((double) height) / (max[1] - min[1]);    // we pass in the colors for each of the preds so now we just do it     // once.    pcursor.reset();    int x, y, w, h;    //    for (int i = 0; i < pcursor.numElems(); i++) {	    while (pcursor.getNext(key, keyLen, keyLevel, keyColor) != eEOF) {	// if on leaf, plot a point ...	if (keyLevel == 1) {	    rt_point pt(dim, (const double *) key);	    x = (int) floor((pt.co(0) - min[0]) * scales[0]);	    y = height - (int) floor((pt.co(1) - min[1]) * scales[1]);		    env->CallVoidMethod(graphicsContext, setColorId, colors[keyColor]);	    env->CallVoidMethod(graphicsContext, drawRectId, x, y, 1, 1);	} else {	    rt_bounding_sphere s(dim, (const double *) key);	    x = (int) floor((s.center.co(0) - min[0]) * scales[0]);	    y = (int) floor((s.center.co(1) - min[1]) * scales[1]);		    w = (int) floor((s.radius()) * scales[0]);	    h = (int) floor((s.radius()) * scales[1]);	    env->CallVoidMethod(graphicsContext, setColorId, colors[keyColor]);	    y = height - y;	    env->CallVoidMethod(graphicsContext, drawOvalId, 		(x - w), (y - h), 2*w, 2*h);	}    }    return(RCOK);}rc_tamdb_support::display_ss_point_preds(	JNIEnv* env,	jint    width,	jint    height,	jobject graphicsContext, // in: Java class: java.awt.Graphics	jobject colors[], // in: array of java.awt.Color objects	gist_disppredcursor_t& pcursor) // in: predicates to display{    if (pcursor.numPreds() == 0) return RCOK; // nothing to display ...    initIds(env, graphicsContext);    char tempData[gist_p::max_tup_sz];    void *key = (void *) tempData;    int keyLen;    int keyLevel;    int keyColor;    // get initial key so we can determine the number of dims ...    pcursor.getNext(key, keyLen, keyLevel, keyColor);    // we can only display 2-dim data    int dim;    if (keyLevel == 1)	dim = rt_point::size2dim(keyLen);    else 	dim = rt_centroid_sphere::size2dim(keyLen);    //     if (dim != displayDim) {// 	cout << "display() displayDim != dim: " << displayDim // 	     << " " << dim << endl;//         return RCOK;//     }    // find min/max along each dimension    double min[displayDim];    double max[displayDim];        int j;        double tmin, tmax;        // initialize the ranges along each dimension ...    if (keyLevel == 1) {	rt_point pt(dim, (const double *) key);	for (j = 0; j < displayDim; j++) {	    min[j] = pt.co(j);	    max[j] = pt.co(j);	}    } else {	rt_centroid_sphere s(dim, (const double *) key);	for (j = 0; j < displayDim; j++) {	    tmin = s.center.co(j) - s.radius();	    tmax = s.center.co(j) + s.radius();	    min[j] = tmin;	    max[j] = tmax;	}    }    while (pcursor.getNext(key, keyLen, keyLevel, keyColor) != eEOF) {	// If level is one then its a leaf ... 	if (keyLevel == 1) {	    rt_point pt(dim, (const double *) key);	    for (j = 0; j < displayDim; j++) {		if (min[j] > pt.co(j)) min[j] = pt.co(j);		if (max[j] < pt.co(j)) max[j] = pt.co(j);	    }	} else {	    rt_centroid_sphere s(dim, (const double *) key);	    for (j = 0; j < displayDim; j++) {		tmin = s.center.co(j) - s.radius();		tmax = s.center.co(j) + s.radius();		if (min[j] > tmin) min[j] = tmin;		if (max[j] < tmax) max[j] = tmax;	    }	}    }     int notok = drawScales(&width, &height, min[0], max[0], min[1], max[1],	env, graphicsContext);        if (notok)	return notok;    double scales[displayDim];    scales[0] = ((double) width) / (max[0] - min[0]);    scales[1] = ((double) height) / (max[1] - min[1]);    // we pass in the colors for each of the preds so now we just do it     // once.    pcursor.reset();    int x, y, w, h;    //    for (int i = 0; i < pcursor.numElems(); i++) {	    while (pcursor.getNext(key, keyLen, keyLevel, keyColor) != eEOF) {	// if on leaf, plot a point ...	if (keyLevel == 1) {	    rt_point pt(dim, (const double *) key);	    x = (int) floor((pt.co(0) - min[0]) * scales[0]);	    y = height - (int) floor((pt.co(1) - min[1]) * scales[1]);		    env->CallVoidMethod(graphicsContext, setColorId, colors[keyColor]);	    env->CallVoidMethod(graphicsContext, drawRectId, x, y, 1, 1);	} else {	    rt_bounding_sphere s(dim, (const double *) key);	    x = (int) floor((s.center.co(0) - min[0]) * scales[0]);	    y = (int) floor((s.center.co(1) - min[1]) * scales[1]);		    w = (int) floor((s.radius()) * scales[0]);	    h = (int) floor((s.radius()) * scales[1]);	    env->CallVoidMethod(graphicsContext, setColorId, colors[keyColor]);	    y = height - y;	    env->CallVoidMethod(graphicsContext, drawOvalId, 		(x - w), (y - h), 2*w, 2*h);	}    }    return(RCOK);}rc_tamdb_support::display_sr_point_preds(	JNIEnv* env,	jint    width,	jint    height,	jobject graphicsContext, // in: Java class: java.awt.Graphics	jobject colors[], // in: array of java.awt.Color objects	gist_disppredcursor_t& pcursor) // in: predicates to display{    if (pcursor.numPreds() == 0) return RCOK; // nothing to display ...    initIds(env, graphicsContext);    char tempData[gist_p::max_tup_sz];    void *key = (void *) tempData;    int keyLen;    int keyLevel;    int keyColor;    // get initial key so we can determine the number of dims ...    pcursor.getNext(key, keyLen, keyLevel, keyColor);    // we can only display 2-dim data    int dim;    if (keyLevel == 1)	dim = rt_point::size2dim(keyLen);    else 	dim = rt_sphererect::size2dim(keyLen);    //     if (dim != displayDim) {// 	cout << "display() displayDim != dim: " << displayDim // 	     << " " << dim << endl;//         return RCOK;//     }    // find min/max along each dimension    double min[displayDim];    double max[displayDim];    int j;    double tmin, tmax;        // initialize the ranges along each dimension ...    if (keyLevel == 1) {	rt_point pt(dim, (const double *) key);	for (j = 0; j < displayDim; j++) {	    min[j] = pt.co(j);	    max[j] = pt.co(j);	}    } else {	rt_sphererect sr(dim, (const double *) key);	rt_rect& r = sr.rect;	rt_centroid_sphere& s = sr.sphere;	for (j = 0; j < displayDim; j++) {	    tmin = s.center.co(j) - s.radius();	    tmax = s.center.co(j) + s.radius();	    if (tmin > r.lo(j))		tmin = r.lo(j);	    if (tmax < r.hi(j))		tmax = r.hi(j);	    min[j] = tmin;	    max[j] = tmax;	}    }    while (pcursor.getNext(key, keyLen, keyLevel, keyColor) != eEOF) {	// If level is one then its a leaf ... 	if (keyLevel == 1) {	    rt_point pt(dim, (const double *) key);	    for (j = 0; j < displayDim; j++) {		if (min[j] > pt.co(j)) min[j] = pt.co(j);		if (max[j] < pt.co(j)) max[j] = pt.co(j);	    }	} else {	    rt_sphererect sr(dim, (const double *) key);	    rt_rect& r = sr.rect;	    rt_centroid_sphere& s = sr.sphere;	    for (j = 0; j < displayDim; j++) {		tmin = s.center.co(j) - s.radius();		tmax = s.center.co(j) + s.radius();		if (tmin > r.lo(j))		    tmin = r.lo(j);		if (tmax < r.hi(j))		    tmax = r.hi(j);		if (min[j] > tmin) min[j] = tmin;		if (max[j] < tmax) max[j] = tmax;	    }	}    }    int notok = drawScales(&width, &height, min[0], max[0], min[1], max[1],	env, graphicsContext);        if (notok)	return notok;    double scales[displayDim];    scales[0] = ((double) width) / (max[0] - min[0]);    scales[1] = ((double) height) / (max[1] - min[1]);    // we pass in the colors for each of the preds so now we just do it     // once.    pcursor.reset();    int x, y, w, h, x1, x2, y1, y2;    while (pcursor.getNext(key, keyLen, keyLevel, keyColor) != eEOF) {	// if on leaf, plot a point ...	if (keyLevel == 1) {	    rt_point pt(dim, (const double *) key);	    x = (int) floor((pt.co(0) - min[0]) * scales[0]);	    y = height - (int) floor((pt.co(1) - min[1]) * scales[1]);		    env->CallVoidMethod(graphicsContext, setColorId, colors[keyColor]);	    env->CallVoidMethod(graphicsContext, drawRectId, x, y, 1, 1);	} else {	    rt_sphererect sr(dim, (const double *) key);	    rt_rect& r = sr.rect;	    rt_centroid_sphere& s = sr.sphere;	    x1 = (int) floor((r.lo(0) - min[0]) * scales[0]);	    x2 = (int) floor((r.hi(0) - min[0]) * scales[0]);	    y1 = height - (int) floor((r.lo(1) - min[1]) * scales[1]);	    y2 = height - (int) floor((r.hi(1) - min[1]) * scales[1]);	    x = (int) floor((s.center.co(0) - min[0]) * scales[0]);	    y = height - (int) floor((s.center.co(1) - min[1]) * scales[1]);		    w = (int) floor((s.radius()) * scales[0]);	    h = (int) floor((s.radius()) * scales[1]);	    env->CallVoidMethod(graphicsContext, setColorId, colors[keyColor]);	    env->CallVoidMethod(graphicsContext, drawOvalId, 		(x - w), (y - h), 2*w, 2*h);	    env->CallVoidMethod(graphicsContext, drawRectId, 		x1, y2, x2-x1, abs(y2-y1));	}    }    return(RCOK);}rc_tamdb_support::display_rt_rect_preds(    JNIEnv* env,    jint    width,    jint    height,    jobject graphicsContext, // in: Java class: java.awt.Graphics    jobject colors[], // in: array of java.awt.Color objects    gist_disppredcursor_t& pcursor) // in: predicates to display{    if (pcursor.numPreds() == 0) return RCOK; // nothing to display ...    initIds(env, graphicsContext);    char tempData[gist_p::max_tup_sz];    void *key = (void *) tempData;    int keyLen;    int keyLevel;    int keyColor;    // get initial key so we can determine the number of dims ...    pcursor.getNext(key, keyLen, keyLevel, keyColor);    // we can only display 2-dim data    int dim;    dim = rt_rect::size2dim(keyLen);    //     if (dim != displayDim) {// 	cout << "display() displayDim != dim: " << displayDim // 	     << " " << dim << endl;//         return RCOK;//     }    // find min/max along each dimension    double min[displayDim];    double max[displayDim];        int j;    // initialize the ranges along each dimension ...    rt_rect r(dim, (const double *) key);    for (j = 0; j < displayDim; j++) {	min[j] = r.lo(j);	max[j] = r.hi(j);    }    while (pcursor.getNext(key, keyLen, keyLevel, keyColor) != eEOF) {	rt_rect r(dim, (const double *) key);	for (j = 0; j < displayDim; j++) {	    if (min[j] > r.lo(j)) min[j] = r.lo(j);	    if (max[j] < r.hi(j)) max[j] = r.hi(j);	}    }     int notok = drawScales(&width, &height, min[0], max[0], min[1], max[1],	env, graphicsContext);        if (notok)	return notok;    double scales[displayDim];    scales[0] = ((double) width) / (max[0] - min[0]);    scales[1] = ((double) height) / (max[1] - min[1]);    // we pass in the colors for each of the preds so now we just do it     // once.    pcursor.reset();    int x1, x2, y1, y2;    while (pcursor.getNext(key, keyLen, keyLevel, keyColor) != eEOF) {	rt_rect r(dim, (const double *) key);	x1 = (int) floor((r.lo(0) - min[0]) * scales[0]);	x2 = (int) floor((r.hi(0) - min[0]) * scales[0]);	y1 = (int) floor((r.lo(1) - min[1]) * scales[1]);	y2 = (int) floor((r.hi(1) - min[1]) * scales[1]);		env->CallVoidMethod(graphicsContext, setColorId, colors[keyColor]);		y1 = height - y1;	y2 = height - y2;		env->CallVoidMethod(graphicsContext, drawRectId, x1, y2, x2-x1, 	    abs(y2-y1));    }    return(RCOK);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -