~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina6/tina-libs/tina/image/imgSeq_logic.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  *
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  *
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-libs/tina/image/imgSeq_logic.c,v $
 37  * Date    :  $Date: 2005/07/03 23:46:54 $
 38  * Version :  $Revision: 1.8 $
 39  * CVS Id  :  $Id: imgSeq_logic.c,v 1.8 2005/07/03 23:46:54 paul Exp $
 40  */
 41 
 42 /** 
 43  *  @file
 44  *  @brief Functions associated with the Sequence structure - logical stuff to get and set.
 45  *
 46  */
 47 
 48 #include "imgSeq_logic.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #include <config.h>
 52 #endif
 53 
 54 #include <stdio.h>
 55 #include <tina/image/img_SeqDef.h>
 56 
 57 
 58 Sequence       *current_seq = NULL;
 59 
 60 /* seq_get_iscales to get x, y, z, dimensions */
 61 
 62 /* this function only used in csf_count_12 */
 63 void            seq_get_iscales(double *iscx, double *iscy, double *iscz)
 64 {
 65         *iscx = current_seq->dim[0];
 66         *iscy = current_seq->dim[1];
 67         *iscz = current_seq->dim[2];
 68 }
 69 
 70 /*
 71  * to get the current sequence. In future will be a means of getting current
 72  * sequence from the list of sequences
 73  */
 74 Sequence       *seq_get_current(void)
 75 {
 76         return (current_seq);
 77 }
 78 
 79 /* sets the current sequence. in future? will set the list of sequences */
 80 void            seq_set_current(Sequence * seq)
 81 {
 82         current_seq = seq;
 83 }
 84 
 85 
 86 /* get_seq_* functions so you can get the start, current, end of any sequence */
 87 
 88 List           *get_seq_start_el(Sequence * seq)
 89 {
 90         if (seq == NULL)
 91                 return (NULL);
 92 
 93         return (seq->start);
 94 }
 95 
 96 
 97 List           *get_seq_end_el(Sequence * seq)
 98 {
 99         if (seq == NULL)
100                 return (NULL);
101 
102         return (seq->end);
103 }
104 
105 
106 List           *get_seq_current_el(Sequence * seq)
107 {
108         if (seq == NULL)
109                 return (NULL);
110 
111         return (seq->current);
112 }
113 
114 /* Functions to set the current list el, given a particular sequence */
115 
116 void            set_seq_current_el(Sequence * seq, List * el)
117 {
118         if (seq != NULL)
119                 seq->current = el;
120 }
121 
122 void            set_seq_start_el(Sequence * seq, List * el)
123 {
124         if (seq != NULL)
125                 seq->start = el;
126 }
127 
128 void            set_seq_end_el(Sequence * seq, List * el)
129 {
130         if (seq != NULL)
131                 seq->end = el;
132 }
133 
134 /*
135  * set_seq_current_frame takes a sequence and frame number, calculates how
136  * many imrects into the sequence this is, traverses imrect list until finds
137  * correct frame, and sets this list element as the current el.
138  */
139 
140 void            set_seq_current_frame(Sequence * seq, int frame)
141 {
142         List           *lptr = NULL;
143         List           *start = NULL;
144         int             count, dest;
145 
146         if ((start = get_seq_start_el(seq)) == NULL)
147                 return;
148 
149         dest = frame - seq->offset;
150         count = 0;
151 
152         for (lptr = start; lptr != NULL; lptr = lptr->next)
153         {
154                 if (dest == count)
155                         break;
156 
157                 count = count + seq->stride;
158         }
159 
160         seq->current = lptr;
161 
162 }
163 
164 int             get_seq_current_frame(Sequence * seq)
165 {
166         List           *lptr = NULL;
167         List           *start = NULL;
168         int             count;
169 
170         if ((start = get_seq_start_el(seq)) == NULL)
171                 return -1;
172 
173         count = 0; 
174         /* mjs 10.10.03 Changing this back to start count at 0 due to inconsistency with 
175            segmentation code. Logically, the count should only be incremented by 1 too. */
176         
177         for (lptr = start; lptr != seq->current; lptr = lptr->next)
178         {
179                 count += seq->stride;
180         }
181         return (count);
182 }
183 
184 /*
185  * get_current_seq_* functions so you can get start, current and end elements
186  * of the Current sequence
187  */
188 
189 List           *get_current_seq_start_el(void)
190 {
191         Sequence       *seq = seq_get_current();
192 
193         if (seq == NULL)
194                 return (NULL);
195 
196         return (get_seq_start_el(seq));
197 }
198 
199 List           *get_current_seq_end_el(void)
200 {
201         Sequence       *seq = seq_get_current();
202 
203         if (seq == NULL)
204                 return (NULL);
205 
206         return (get_seq_end_el(seq));
207 }
208 
209 List           *get_current_seq_current_el(void)
210 {
211         Sequence       *seq = seq_get_current();
212 
213         if (seq == NULL)
214                 return (NULL);
215 
216         return (get_seq_current_el(seq));
217 }
218 
219 /* set_current_seq_current_frame sets the frame of the current sequence */
220 
221 void            set_current_seq_current_frame(int frame)
222 {
223         Sequence       *seq = seq_get_current();
224 
225         set_seq_current_frame(seq, frame);
226 
227 }
228 
229 /* sets the current , start and end els of the current sequence */
230 
231 void            set_current_seq_current_el(List * el)
232 {
233 
234         Sequence       *seq = seq_get_current();
235 
236         set_seq_current_el(seq, el);
237 
238 }
239 
240 
241 void            set_current_seq_start_el(List * el)
242 {
243 
244         Sequence       *seq = seq_get_current();
245 
246         set_seq_start_el(seq, el);
247 
248 }
249 
250 
251 void            set_current_seq_end_el(List * el)
252 {
253 
254         Sequence       *seq = seq_get_current();
255 
256         set_seq_end_el(seq, el);
257 
258 }
259 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.