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

Linux Cross Reference
Tina6/tina-tools/tinatool/tlmedical/tlmedOctants_alloc.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    :
 37  * Date    :
 38  * Version :
 39  * CVS Id  :
 40  *
 41  * Notes : Allocation and freeing functions for major octants tool structures
 42  *
 43  *********
 44 */
 45 
 46 #include <tina/sys/sysDef.h>
 47 #include <tina/sys/sysPro.h>
 48 #include "tlmedOctants_csfcount12.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #    include <config.h>
 52 #endif
 53 
 54 
 55 Octants *octants_alloc(void)
 56 {
 57         Octants *octants=NULL;
 58 
 59         octants = talloc(Octants);
 60 
 61         octants->name = (char *)cvector_alloc(0, 32);
 62         octants->a = (double *)dvector_alloc(0, 15);
 63         return octants;
 64 }
 65 
 66 
 67 Octants *octants_free(Octants *octants)
 68 {
 69         char *name=NULL;
 70         double *a=NULL;
 71 
 72         a = octants->a;
 73         name = octants->name;
 74 
 75         name = cvector_free(name, 0);
 76         a = dvector_free(a, 0);
 77         rfree((void *)octants);
 78 
 79         return NULL;
 80 }
 81 
 82 
 83 List *center_point_list_destroy(List *center_point_list)
 84 {
 85         List *nlist;
 86         Match *nptr;
 87         double *data;
 88         float *weight_vector;
 89 
 90         for (nlist = center_point_list; nlist!=NULL; nlist = nlist->next)
 91         {
 92                 nptr = nlist->to;
 93                 data = nptr->to1;
 94                 weight_vector = nptr->to2;
 95                 dvector_free(data,0);
 96                 fvector_free(weight_vector, 0);
 97                 match_free(nptr);
 98         }
 99 
100         dd_list_rm_links(center_point_list);
101 
102         return(NULL);
103 }
104 
105 
106 List *center_point_init(int cimptrlx, int cimptrux, int cimptrly, int cimptruy, int cimptrlz, int cimptruz)
107 {
108         Match *nptr=NULL;
109         double x1, x2, y1, y2, z1, z2, z3;
110         double center_point[12][3], *center_point_copy=NULL;
111         float *weight_vector=NULL;
112         int i, j, k;
113         List *center_point_list=NULL;
114 
115         /* Init the list of center points with some sensible values, equivalent to the boxes used previously */
116 
117         x1 = 0.5+ ((double)(cimptrux + 3*cimptrlx))/4;
118         y1 = 0.5+ ((double)(cimptruy + 3*cimptrly))/4;
119         y2 = 0.5+ ((double)(3*cimptruy + cimptrly))/4;
120         z1 = 0.5+ ((double)(cimptruz + 5*cimptrlz))/6;
121         z2 = 0.5+ ((double)(cimptruz + cimptrlz))/2;
122         z3 = 0.5+ ((double)(5*cimptruz + cimptrlz))/6;
123 
124         for(j=0; j<2; j++)
125         {
126                 for(k=0; k<3; k++)
127                 {
128                         center_point[(k+3*j)][0] = x1;
129                 
130                         if(j==0)
131                         {
132                                 center_point[(k+3*j)][1] = y1;
133                         }
134                         else
135                         {
136                                 center_point[(k+3*j)][1] = y2;
137                         }
138                         if(k==0)
139                         {
140                                 center_point[(k+3*j)][2] = z1;
141                         }
142                         else if(k==1)
143                         {
144                                 center_point[(k+3*j)][2] = z2;
145                         }
146                         else
147                         {
148                                 center_point[(k+3*j)][2] = z3;
149                         }
150                 }
151         }
152 
153         for(i=5; i>=0; i--)
154         {
155                 nptr = match_alloc(i);
156                 center_point_copy = dvector_alloc(0, 3);
157                 weight_vector = fvector_alloc(0, 2);
158                 for(j=0; j<3; j++) center_point_copy[j] = center_point[i][j];
159                 nptr->to1 = center_point_copy;
160                 nptr->to2 = weight_vector;
161                 nptr->weight = 0;
162                 center_point_list = link_addtostart(center_point_list, link_alloc(nptr, 1001));
163         }
164         return(center_point_list);
165 }
166 

~ [ 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.