- Timestamp:
- Jul 15, 2010, 6:30:19 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/psModules/src/objects/pmSource.c
r28643 r28676 105 105 static int id = 1; 106 106 pmSource *source = (pmSource *) psAlloc(sizeof(pmSource)); 107 *(int *)&source->id = id++; 107 P_PM_SOURCE_SET_ID(source, id++); 108 108 109 source->seq = -1; 109 110 source->peak = NULL; … … 149 150 150 151 /****************************************************************************** 151 pmSourceCopy(): copy the pmSource structure and contents 152 XXX : are we OK with incrementing the ID? 152 pmSourceCopy(): copy the pmSource, yielding a copy of the source that can be used without 153 affecting the original. This Copy can be used to allow multiple fit attempts on the same 154 object. The pixels, variance, and mask arrays all point to the same original subarrays. The 155 peak and moments point at the original values. 153 156 *****************************************************************************/ 154 157 pmSource *pmSourceCopy(pmSource *in) 158 { 159 if (in == NULL) { 160 return(NULL); 161 } 162 pmSource *source = pmSourceAlloc (); 163 164 // keep the original ID so we can find map back to the original 165 P_PM_SOURCE_SET_ID(source, in->id); 166 167 // peak has the same values as the original 168 if (in->peak != NULL) { 169 source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->value, in->peak->type); 170 source->peak->xf = in->peak->xf; 171 source->peak->yf = in->peak->yf; 172 source->peak->flux = in->peak->flux; 173 source->peak->SN = in->peak->SN; 174 } 175 176 // copy the values in the moments structure 177 if (in->moments != NULL) { 178 source->moments = pmMomentsAlloc(); 179 *source->moments = *in->moments; 180 } 181 182 // These images are all views to the parent. We want a new view, but pointing at the same 183 // pixels. Modifying these pixels (ie, subtracting the model) will affect the pixels seen 184 // by all copies. 185 source->pixels = psImageCopyView(NULL, in->pixels); 186 source->variance = psImageCopyView(NULL, in->variance); 187 source->maskView = in->maskView ? psImageCopyView(NULL, in->maskView) : NULL; 188 189 // the maskObj is a unique mask array; create a new mask image 190 source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL; 191 192 source->type = in->type; 193 source->mode = in->mode; 194 source->imageID = in->imageID; 195 196 return(source); 197 } 198 199 /****************************************************************************** 200 pmSourceCopyData(): this creates a new, duplicate source with the same parameters as the 201 original (but is actually a new source at the same location) 202 *****************************************************************************/ 203 pmSource *pmSourceCopyData(pmSource *in) 155 204 { 156 205 if (in == NULL) {
Note:
See TracChangeset
for help on using the changeset viewer.
