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_voi.c,v $
37 * Date : $Date: 2003/09/30 16:53:49 $
38 * Version : $Revision: 1.6 $
39 * CVS Id : $Id: imgSeq_voi.c,v 1.6 2003/09/30 16:53:49 ipoole Exp $
40 *
41 * Author : Legacy TINA
42 */
43
44 /**
45 * @file
46 * @brief Volume of interest defined by a list of spline approximations
47 * to string data structures.
48 *
49 * For those who need something more than a rectangle to define a regions of interest.
50 *
51 */
52
53 // Modified to remove all snake stuff MLJS 29/11/00
54
55
56 #include "imgSeq_voi.h"
57
58 #if HAVE_CONFIG_H
59 #include <config.h>
60 #endif
61
62 #include <math.h>
63
64 #include <tina/sys/sysDef.h>
65 #include <tina/sys/sysPro.h>
66 #include <tina/math/mathDef.h>
67 #include <tina/math/mathPro.h>
68 #include <tina/geometry/geomDef.h>
69 #include <tina/geometry/geomPro.h>
70 #include <tina/image/img_SeqDef.h>
71
72 Seqvoi *svoi_alloc(void)
73 {
74 Seqvoi *voi = (Seqvoi *) ralloc(sizeof(Seqvoi));
75
76 voi->string = NULL;
77 voi->spline = NULL;
78 return (voi);
79 }
80
81 void svoi_free(Seqvoi * voi)
82 {
83 if (voi == NULL)
84 return;
85 str_free(voi->string, rfree);
86 spline2_free(voi->spline);
87 rfree(voi);
88 }
89
90 void svoi_empty(Seqvoi * voi)
91 {
92 if (voi == NULL)
93 return;
94 spline2_free(voi->spline);
95 voi->spline = NULL;
96 str_free(voi->string, rfree);
97 voi->string = NULL;
98 }
99
100 void svoi_string_changed(Seqvoi * voi)
101 {
102 if (voi == NULL)
103 return;
104 spline2_free(voi->spline);
105 voi->spline = NULL;
106 voi->n = 0;
107 }
108
109 /*
110 void svoi_spline_changed(Seqvoi * voi)
111 {
112 if (voi == NULL)
113 return;
114 str_free(voi->string, rfree);
115 voi->string = NULL;
116 }
117 */
118
119
120 Tstring *svoi_string_get(Seqvoi * voi)
121 {
122 if (voi == NULL)
123 return (NULL);
124
125 if (voi->string != NULL)
126 return (voi->string);
127
128 if (voi->spline != NULL)
129 {
130 voi->string = str2_of_spline2(voi->spline);
131 return (voi->string);
132 }
133 return (NULL);
134 }
135
136 Seqvoi *svoi_copy(Seqvoi * oldvoi)
137 {
138 Seqvoi *voi = (Seqvoi *) ralloc(sizeof(Seqvoi));
139 voi->string = str2_copy(svoi_string_get(oldvoi));
140 voi->spline = NULL;
141 voi->nspline = oldvoi->nspline;
142 voi->n = oldvoi->n;
143 return (voi);
144 }
145
146
147 void svoi_string_set(Seqvoi * voi, Tstring * str)
148 {
149 svoi_empty(voi);
150 if (str2_area(str) < 0.0)
151 str_reverse(str);
152 voi->string = str;
153 }
154
155 Spline2 *svoi_spline_get(Seqvoi * voi)
156 {
157 Tstring *string;
158
159 if (voi == NULL)
160 return (NULL);
161 if (voi->spline != NULL)
162 return (voi->spline);
163
164 string = svoi_string_get(voi);
165 if (string == NULL)
166 return (NULL);
167 // this was commented out
168 // a.lacey@man.ac.uk 8.9.03
169 else
170 {
171 int n = 8;
172 voi->spline = spline2_approx_str2(string, &n, 1.0);
173 return (voi->spline);
174 }
175 }
176
177 void svoi_spline_set(Seqvoi * voi, Spline2 * spline)
178 {
179 svoi_empty(voi);
180 voi->spline = spline;
181 }
182
183 void svoi_shift(Seqvoi * voi, Vec2 dp)
184 {
185 Tstring *string = svoi_string_get(voi);
186 str2_translate(string, dp);
187 svoi_string_changed(voi);
188 }
189
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.