/* ******** gageShapeEqual ** ** shapes not being equal is a biffable error, ** returning 0 signifies this "error" ** returning 1 means no error, they ARE equal */ int gageShapeEqual(const gageShape *shape1, const char *_name1, const gageShape *shape2, const char *_name2) { static const char me[]="gageShapeEqual"; const char *name1, *name2, what[] = "???"; if (!( shape1 && shape2 )) { biffAddf(GAGE, "%s: can't judge equality w/ NULL pointer", me); return 0; } name1 = _name1 ? _name1 : what; name2 = _name2 ? _name2 : what; if (!( shape1->fromOrientation == shape2->fromOrientation )) { biffAddf(GAGE, "%s: fromOrientation of %s (%s) != %s's (%s)", me, name1, shape1->fromOrientation ? "true" : "false", name2, shape2->fromOrientation ? "true" : "false"); return 0; } if (!( shape1->size[0] == shape2->size[0] && shape1->size[1] == shape2->size[1] && shape1->size[2] == shape2->size[2] )) { biffAddf(GAGE, "%s: dimensions of %s (%u,%u,%u) != %s's (%u,%u,%u)", me, name1, shape1->size[0], shape1->size[1], shape1->size[2], name2, shape2->size[0], shape2->size[1], shape2->size[2]); return 0; } if (shape1->fromOrientation) { if (!( ELL_4M_EQUAL(shape1->ItoW, shape2->ItoW) )) { biffAddf(GAGE, "%s: ItoW matrices of %s and %s not the same", me, name1, name2); return 0; } } else { if (!( shape1->spacing[0] == shape2->spacing[0] && shape1->spacing[1] == shape2->spacing[1] && shape1->spacing[2] == shape2->spacing[2] )) { biffAddf(GAGE, "%s: spacings of %s (%g,%g,%g) != %s's (%g,%g,%g)", me, name1, shape1->spacing[0], shape1->spacing[1], shape1->spacing[2], name2, shape2->spacing[0], shape2->spacing[1], shape2->spacing[2]); return 0; } if (!( shape1->center == shape2->center )) { biffAddf(GAGE, "%s: centering of %s (%s) != %s's (%s)", me, name1, airEnumStr(nrrdCenter, shape1->center), name2, airEnumStr(nrrdCenter, shape2->center)); return 0; } } return 1; }
int gageShapeEqual(gageShape *shape1, char *_name1, gageShape *shape2, char *_name2) { char me[]="_gageShapeEqual", err[BIFF_STRLEN], *name1, *name2, what[] = "???"; name1 = _name1 ? _name1 : what; name2 = _name2 ? _name2 : what; if (!( shape1->fromOrientation == shape2->fromOrientation )) { sprintf(err, "%s: fromOrientation of %s (%s) != %s's (%s)", me, name1, shape1->fromOrientation ? "true" : "false", name2, shape2->fromOrientation ? "true" : "false"); biffAdd(GAGE, err); return 0; } if (!( shape1->size[0] == shape2->size[0] && shape1->size[1] == shape2->size[1] && shape1->size[2] == shape2->size[2] )) { sprintf(err, "%s: dimensions of %s (%u,%u,%u) != %s's (%u,%u,%u)", me, name1, shape1->size[0], shape1->size[1], shape1->size[2], name2, shape2->size[0], shape2->size[1], shape2->size[2]); biffAdd(GAGE, err); return 0; } if (shape1->fromOrientation) { if (!( ELL_4M_EQUAL(shape1->ItoW, shape2->ItoW) )) { sprintf(err, "%s: ItoW matrices of %s and %s not the same", me, name1, name2); biffAdd(GAGE, err); return 0; } } else { if (!( shape1->spacing[0] == shape2->spacing[0] && shape1->spacing[1] == shape2->spacing[1] && shape1->spacing[2] == shape2->spacing[2] )) { sprintf(err, "%s: spacings of %s (%g,%g,%g) != %s's (%g,%g,%g)", me, name1, shape1->spacing[0], shape1->spacing[1], shape1->spacing[2], name2, shape2->spacing[0], shape2->spacing[1], shape2->spacing[2]); biffAdd(GAGE, err); return 0; } if (!( shape1->center == shape2->center )) { sprintf(err, "%s: centering of %s (%s) != %s's (%s)", me, name1, airEnumStr(nrrdCenter, shape1->center), name2, airEnumStr(nrrdCenter, shape2->center)); biffAdd(GAGE, err); return 0; } } return 1; }