|
From: <kin...@us...> - 2024-07-12 19:10:34
|
Revision: 7205
http://sourceforge.net/p/teem/code/7205
Author: kindlmann
Date: 2024-07-12 19:10:32 +0000 (Fri, 12 Jul 2024)
Log Message:
-----------
usefully acting on float-type data
Modified Paths:
--------------
teem/trunk/src/limn/splineFit.c
Modified: teem/trunk/src/limn/splineFit.c
===================================================================
--- teem/trunk/src/limn/splineFit.c 2024-07-11 22:19:19 UTC (rev 7204)
+++ teem/trunk/src/limn/splineFit.c 2024-07-12 19:10:32 UTC (rev 7205)
@@ -197,8 +197,9 @@
biffAddf(LIMN, "%s: couldn't allocate point container", me);
return NULL;
}
- if (pdata) {
- /* we are wrapping around a given pre-allocated buffer */
+ if (pdata && nrrdTypeDouble == ptype) {
+ /* we are wrapping around a given pre-allocated buffer
+ and it just happens to already be type double */
lpnt->pp = pdata;
lpnt->ppOwn = NULL;
} else {
@@ -206,8 +207,24 @@
lpnt->pp = NULL;
if (!(lpnt->ppOwn = AIR_CALLOC(dim * pnum, double))) {
biffAddf(LIMN, "%s: couldn't allocate %u %u-D point", me, pnum, dim);
+ free(lpnt);
return NULL;
}
+ if (pdata) {
+ uint ii, nn = dim * pnum;
+ if (nrrdTypeFloat == ptype) {
+ const float *fdata = (const float *)pdata;
+ for (ii = 0; ii < nn; ii++) {
+ lpnt->ppOwn[ii] = (double)fdata[ii];
+ }
+ } else {
+ biffAddf(LIMN, "%s: sorry, can't currently handle given %s type data", me,
+ airEnumStr(nrrdType, ptype));
+ free(lpnt->ppOwn);
+ free(lpnt);
+ return NULL;
+ }
+ }
}
lpnt->num = pnum;
lpnt->dim = dim; /* but really DIM=2 because of above */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|