Changeset 23241
- Timestamp:
- Mar 9, 2009, 4:02:26 PM (17 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 2 edited
-
pmSourceMatch.c (modified) (11 diffs)
-
pmSourceMatch.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourceMatch.c
r23233 r23241 16 16 #define SOURCE_FAINTEST 50.0 // Faintest magnitude to consider 17 17 #define SOURCES_MAX_LEAF 2 // Maximum number of points on a tree leaf 18 18 #define ARRAY_BUFFER 16 // Buffer for array 19 19 20 20 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 113 113 } 114 114 115 pmSourceMatch *pmSourceMatchAlloc(int num // Maximum number of images 116 ) 115 pmSourceMatch *pmSourceMatchAlloc(void) 117 116 { 118 117 pmSourceMatch *match = psAlloc(sizeof(pmSourceMatch)); // Match data … … 120 119 121 120 match->num = 0; 122 match->mag = psVectorAllocEmpty( num, PS_TYPE_F32);123 match->magErr = psVectorAllocEmpty( num, PS_TYPE_F32);124 match->image = psVectorAllocEmpty( num, PS_TYPE_U32);125 match->index = psVectorAllocEmpty( num, PS_TYPE_U32);126 match->mask = psVectorAllocEmpty( num, PS_TYPE_VECTOR_MASK);121 match->mag = psVectorAllocEmpty(ARRAY_BUFFER, PS_TYPE_F32); 122 match->magErr = psVectorAllocEmpty(ARRAY_BUFFER, PS_TYPE_F32); 123 match->image = psVectorAllocEmpty(ARRAY_BUFFER, PS_TYPE_U32); 124 match->index = psVectorAllocEmpty(ARRAY_BUFFER, PS_TYPE_U32); 125 match->mask = psVectorAllocEmpty(ARRAY_BUFFER, PS_TYPE_VECTOR_MASK); 127 126 128 127 return match; … … 136 135 { 137 136 int num = match->num; // Number of matches 138 psAssert(num <= match->mag->nalloc, "Too many matches."); 139 psAssert(num <= match->magErr->nalloc, "Too many matches."); 140 psAssert(num <= match->image->nalloc, "Too many matches."); 141 psAssert(num <= match->index->nalloc, "Too many matches."); 137 138 match->mag = psVectorExtend(match->mag, match->mag->nalloc, 1); 139 match->magErr = psVectorExtend(match->magErr, match->magErr->nalloc, 1); 140 match->image = psVectorExtend(match->image, match->image->nalloc, 1); 141 match->index = psVectorExtend(match->index, match->index->nalloc, 1); 142 match->mask = psVectorExtend(match->mask, match->mask->nalloc, 1); 142 143 143 144 match->mag->data.F32[num] = mag; … … 148 149 match->num++; 149 150 150 match->mag->n = match->magErr->n = match->image->n = match->index->n = match->mask->n = match->num;151 return; 151 152 } 152 153 … … 185 186 matches = psArrayAlloc(numSources); 186 187 for (int j = 0; j < numSources; j++) { 187 pmSourceMatch *match = pmSourceMatchAlloc( numImages); // Match data188 pmSourceMatch *match = pmSourceMatchAlloc(); // Match data 188 189 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 189 190 matches->data[j] = match; 190 191 } 191 192 numMaster += numSources; 192 goto match_image_done; 193 } 194 195 if (boundsImage->x0 > boundsMaster->x1 || boundsImage->x1 < boundsMaster->x0 || 196 boundsImage->y0 > boundsMaster->y1 || boundsImage->y1 < boundsMaster->y0) { 193 } else if (boundsImage->x0 > boundsMaster->x1 || boundsImage->x1 < boundsMaster->x0 || 194 boundsImage->y0 > boundsMaster->y1 || boundsImage->y1 < boundsMaster->y0) { 195 // Bounds don't overlap --- can just add everything in to the master list 197 196 psTrace("psModules.objects", 7, "Bounds don't overlap\n"); 198 // Add everything in to the master list199 197 long size = numMaster + numSources; // New size 200 198 xMaster = psVectorRealloc(xMaster, size); … … 207 205 numSources * PSELEMTYPE_SIZEOF(PS_TYPE_F32)); 208 206 for (int j = 0, k = numMaster; j < numSources; j++, k++) { 209 pmSourceMatch *match = pmSourceMatchAlloc( numImages); // Match data207 pmSourceMatch *match = pmSourceMatchAlloc(); // Match data 210 208 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 211 209 matches->data[k] = match; … … 215 213 yMaster->n = size; 216 214 matches->n = size; 217 218 goto match_image_done; 219 } 220 221 // Match with the master list 222 { 215 } else { 216 // Match with the master list 223 217 psTree *tree = psTreePlant(2, SOURCES_MAX_LEAF, xMaster, yMaster); // kd Tree with sources 224 long numMatch = 0; // Number of matches218 long numMatch = 0; // Number of matches 225 219 226 220 long size = numMaster + numSources; // New size … … 241 235 } else { 242 236 // Add to the master list 243 pmSourceMatch *match = pmSourceMatchAlloc( numImages); // Match data237 pmSourceMatch *match = pmSourceMatchAlloc(); // Match data 244 238 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 245 239 xMaster->data.F32[numMaster] = xImage->data.F32[j]; … … 255 249 } 256 250 257 match_image_done:258 251 psFree(boundsImage); 259 252 psFree(xImage); … … 306 299 continue; 307 300 } 308 int im age= match->image->data.S32[j]; // Index of image309 int index = match->index->data.S32[j]; // Index of source for image310 psArray *list = sourceArrays->data[im age]; // List of interest311 source = list->data[ index];301 int imgIndex = match->image->data.S32[j]; // Index of image 302 int srcIndex = match->index->data.S32[j]; // Index of source for image 303 psArray *list = sourceArrays->data[imgIndex]; // List of interest 304 source = list->data[srcIndex]; 312 305 break; 313 306 } -
trunk/psModules/src/objects/pmSourceMatch.h
r23233 r23241 33 33 34 34 /// Allocator for pmSourceMatch 35 pmSourceMatch *pmSourceMatchAlloc(int num // Maximum number of images 36 ); 35 pmSourceMatch *pmSourceMatchAlloc(void); 37 36 38 37 /// Add a source to a match
Note:
See TracChangeset
for help on using the changeset viewer.
