1 /* 2 Teem: Tools to process and visualize scientific data and images . 3 Copyright (C) 2012, 2011, 2010, 2009 University of Chicago 4 Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann 5 Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah 6 7 This library is free software; you can redistribute it and/or 8 modify it under the terms of the GNU Lesser General Public License 9 (LGPL) as published by the Free Software Foundation; either 10 version 2.1 of the License, or (at your option) any later version. 11 The terms of redistributing and/or modifying this software also 12 include exceptions to the LGPL that facilitate static linking. 13 14 This library is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 Lesser General Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public License 20 along with this library; if not, write to Free Software Foundation, Inc., 21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 */ 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /* 29 ** These heuristics/parameters have been adjusted, and don't seem to need 30 ** any further tweaking in order to work for all the datasets used so far 31 */ 32 33 /* size/allocation increment for per-bin airArray */ 34 #define _PULL_BIN_INCR 32 35 36 /* size/allocation increment for pullTrace airArray in pullTraceMulti */ 37 #define _PULL_TRACE_MULTI_INCR 1024 38 39 /* this has to be big enough to do experiments where binning is turned off */ 40 #define _PULL_NEIGH_MAXNUM 4096 41 42 /* used by pullBinsPointMaybeAdd; don't add a point if its (normalized) 43 distance to an existing point is less than this */ 44 #define _PULL_BINNING_MAYBE_ADD_THRESH 0.1 45 46 /* only try adding a point if the normalized neighbor offset sum is 47 greater than this (making this too small only wastes time, by descending 48 and testing a point that can't help reduce energy */ 49 #define _PULL_NEIGH_OFFSET_SUM_THRESH 0.2 50 51 /* how far to place new points from isolated points (as a fraction of 52 radiusSpace), when not using an energy with an explicit well */ 53 #define _PULL_NEWPNT_DIST 0.6 54 55 /* scaling factor between point->neighDistMean and distance cap; higher 56 values allow for more adventurous explorations . . . */ 57 #define _PULL_DIST_CAP_RSNORM 2.0 58 59 /* travel distance limit in terms of voxelSizeSpace and voxelSizeScale */ 60 #define _PULL_DIST_CAP_VOXEL 1.5 61 62 /* where along s axis to probe energySpecS to see if its attractive or 63 repulsive along scale */ 64 #define _PULL_TARGET_DIM_S_PROBE 0.05 65 66 /* tentative new points aren't allowed to move further than this (in 67 rs-normalized space) from the original old point */ 68 #define _PULL_NEWPNT_STRAY_DIST 1.3 69 70 /* fraction of bboxMax[3]-bboxMin[3] to use as step along scale 71 for discrete differencing needed to find the gradient (for 72 moving along scale) and 2nd derivative (for learning gamma) 73 of strength 74 */ 75 #define _PULL_STRENGTH_ENERGY_DELTA_SCALE 0.0002 76 77 /* maximum distance, in multiples of voxelSizeSpace, that a point is 78 allowed to move between start and end of constraint satisfaction */ 79 #define _PULL_CONSTRAINT_TRAVEL_MAX 2 80 81 /* max reasonable value of iterParm->constraintIterMax */ 82 #define _PULL_CONSTRAINT_ITER_MAX 50 83 84 /* the main _iterate() function does progress indication if the number of 85 points is larger than this */ 86 #define _PULL_PROGRESS_POINT_NUM_MIN 100 87 88 /* limit on # times we allow random or halton (non-ppv) seeding to fail */ 89 #define _PULL_RANDOM_SEED_TRY_MAX 1000000 90 91 /* limit on stepEnergy */ 92 #define _PULL_STEP_ENERGY_MAX FLT_MAX 93 94 /* resolution of histogram of (r,s) coords of interactions ("hinter") */ 95 #define _PULL_HINTER_SIZE 601 96 97 /* initPull.c */ 98 extern void _pullInitParmInit(pullInitParm *initParm); 99 extern int _pullInitParmCheck(pullInitParm *iparm); 100 101 /* parmPull.c */ 102 extern void _pullIterParmInit(pullIterParm *iterParm); 103 extern int _pullIterParmCheck(pullIterParm *iterParm); 104 extern void _pullSysParmInit(pullSysParm *sysParm); 105 extern int _pullSysParmCheck(pullSysParm *sysParm); 106 extern void _pullFlagInit(pullFlag *flag); 107 108 /* volumePull.c */ 109 extern pullVolume *_pullVolumeCopy(const pullVolume *pvol); 110 extern int _pullVolumeSetup(pullContext *pctx); 111 extern int _pullInsideBBox(pullContext *pctx, double pos[4]); 112 extern unsigned int _pullVolumeIndex(const pullContext *pctx, 113 const char *volName); 114 115 /* infoPull.c */ 116 extern unsigned int _pullInfoLen[PULL_INFO_MAX+1]; 117 extern void (*_pullInfoCopy[10])(double *, const double *); 118 extern int _pullInfoSetup(pullContext *pctx); 119 120 /* contextPull.c */ 121 extern int _pullContextCheck(pullContext *pctx); 122 123 /* taskPull.c */ 124 extern pullTask *_pullTaskNew(pullContext *pctx, int threadIdx); 125 extern pullTask *_pullTaskNix(pullTask *task); 126 extern int _pullTaskSetup(pullContext *pctx); 127 extern void _pullTaskFinish(pullContext *pctx); 128 129 /* actionPull.c */ 130 extern double _pullPrayCorner[2][2][3]; 131 extern size_t _pullPrayRes[2]; 132 extern double _pullDistLimit(pullTask *task, pullPoint *point); 133 extern double _pullEnergyFromPoints(pullTask *task, pullBin *bin, 134 pullPoint *point, 135 /* output */ 136 double egradSum[4]); 137 extern double _pullPointEnergyTotal(pullTask *task, pullBin *bin, 138 pullPoint *point, int ignoreImage, 139 double force[4]); 140 extern int _pullPointProcessDescent(pullTask *task, pullBin *bin, 141 pullPoint *point, int ignoreImage); 142 extern double _pullEnergyInterParticle(pullContext *pctx, 143 pullPoint *me, const pullPoint *she, 144 double spaceDist, double scaleDist, 145 double egrad[4]); 146 147 /* constraints.c */ 148 extern int _pullConstraintSatisfy(pullTask *task, pullPoint *point, 149 double travelMax, 150 int *constrFailP); 151 extern void _pullConstraintTangent(pullTask *task, pullPoint *point, 152 double proj[9]); 153 extern int _pullConstraintDim(const pullContext *pctx); 154 155 /* pointPull.c */ 156 #if PULL_PHIST 157 extern void _pullPointHistInit(pullPoint *point); 158 extern void _pullPointHistAdd(pullPoint *point, int cond); 159 #else 160 #define _pullPointHistInit(p) /* no-op */ 161 #define _pullPointHistAdd(p, c) /* no-op */ 162 #endif 163 extern double _pullStepInterAverage(const pullContext *pctx); 164 extern double _pullStepConstrAverage(const pullContext *pctx); 165 extern double _pullEnergyTotal(const pullContext *pctx); 166 extern void _pullPointStepEnergyScale(pullContext *pctx, double scale); 167 extern int _pullPointSetup(pullContext *pctx); 168 extern void _pullPointFinish(pullContext *pctx); 169 170 /* popcntl.c */ 171 extern int _pullPointProcessNeighLearn(pullTask *task, pullBin *bin, 172 pullPoint *point); 173 extern int _pullPointProcessAdding(pullTask *task, pullBin *bin, 174 pullPoint *point); 175 extern int _pullPointProcessNixing(pullTask *task, pullBin *bin, 176 pullPoint *point); 177 extern int _pullIterFinishNeighLearn(pullContext *pctx); 178 extern int _pullIterFinishAdding(pullContext *pctx); 179 extern int _pullIterFinishNixing(pullContext *pctx); 180 extern void _pullNixTheNixed(pullContext *pctx); 181 182 /* binningPull.c */ 183 extern void _pullBinInit(pullBin *bin); 184 extern void _pullBinDone(pullBin *bin); 185 extern pullBin *_pullBinLocate(pullContext *pctx, double *pos); 186 extern void _pullBinPointRemove(pullContext *pctx, pullBin *bin, int loseIdx); 187 extern int _pullBinSetup(pullContext *pctx); 188 extern int _pullIterFinishDescent(pullContext *pctx); 189 extern void _pullBinFinish(pullContext *pctx); 190 191 /* corePull.c */ 192 extern int _pullVerbose; 193 extern int _pullProcess(pullTask *task); 194 extern void *_pullWorker(void *_task); 195 extern int _pullIterate(pullContext *pctx, int mode); 196 197 #ifdef __cplusplus 198 } 199 #endif 200