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

Linux Cross Reference
Tina6/tina-tools/tinatool/draw/drawPaint_ucbs.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-tools/tinatool/draw/drawPaint_ucbs.c,v $
 37  * Date    :  $Date: 2003/10/01 16:02:47 $
 38  * Version :  $Revision: 1.2 $
 39  * CVS Id  :  $Id: drawPaint_ucbs.c,v 1.2 2003/10/01 16:02:47 tony Exp $
 40  *
 41  * Author  : Legacy TINA
 42  *
 43  * Notes :
 44  *
 45  *********
 46 */
 47 
 48 #include "drawPaint_ucbs.h"
 49 
 50 #if HAVE_CONFIG_H
 51   #include <config.h>
 52 #endif
 53 
 54 #include <tina/sys/sysDef.h>
 55 #include <tina/sys/sysPro.h>
 56 #include <tina/math/mathDef.h>
 57 #include <tina/math/mathPro.h>
 58 #include <tina/geometry/geomDef.h>
 59 #include <tina/geometry/geomPro.h>
 60 #include <tinatool/draw/draw_TvDef.h>
 61 #include <tinatool/draw/draw_TvPro.h>
 62 #include <tinatool/draw/draw_PaintDef.h>
 63 #include <tinatool/draw/draw_PaintPro.h>
 64 
 65 void    ucbs2_draw_ctrl(Tv * tv, Ucbs2 * ucbs, int i)
 66 {
 67     Vec2    c = {Vec2_id};
 68     Vec2    p = {Vec2_id};
 69 
 70     if (ucbs == NULL)
 71         return;
 72 
 73     switch (ucbs->type)
 74     {                           /** only draw relevant controls **/
 75     case STRING:
 76         if (i < 1 || i > ucbs->n)
 77             return;
 78         break;
 79     case LOOP:
 80         i %= ucbs->n;
 81         if (i <= 0)
 82             i += ucbs->n;
 83         break;
 84     }
 85 
 86     c = vec2(ucbs->cx[i], ucbs->cy[i]);
 87     p = ucbs2_eval(ucbs, i - 1.0);
 88     tv_dot2(tv, c);
 89     tv_line2(tv, c, p);
 90 }
 91 
 92 void    ucbs2_draw_ctrls(Tv * tv, Ucbs2 * ucbs)
 93 {
 94     int     i;
 95 
 96     if (ucbs == NULL)
 97         return;
 98 
 99     for (i = 1; i <= ucbs->n; i++)
100         ucbs2_draw_ctrl(tv, ucbs, i);
101 }
102 
103 void    ucbs2_draw_points(Tv * tv, Ucbs2 * ucbs)
104 {
105     int     i;
106 
107     if (ucbs == NULL)
108         return;
109     for (i = 0; i < ucbs->n; i++)
110         tv_bigdot2(tv, ucbs2_eval(ucbs, (double) i), 2);
111 }
112 
113 static Ipos ucbs2_proj2(Tv * tv, Ucbs2 * ucbs, double t)
114 {
115     Vec2    v = {Vec2_id};
116 
117     v = ucbs2_eval(ucbs, t);
118     return (tv_proj2(tv, v));
119 }
120 
121 void    ucbs2_draw_section(Tv * tv, Ucbs2 * ucbs, int i)
122 {
123     if (ucbs == NULL)
124         return;
125 
126     switch (ucbs->type)
127     {
128     case STRING:
129         if (i < 0 || i >= ucbs->n - 1)
130             return;
131         break;
132     case LOOP:
133         while (i < 0)
134             i += ucbs->n;
135         i %= ucbs->n;
136         break;
137     }
138 
139     curve_draw(tv, ucbs2_proj2, (void *) ucbs, (double) i, i + 1.0);
140 }
141 
142 static double z_plane;
143 
144 static Ipos ucbs2_proj3(Tv * tv, Ucbs2 * ucbs, double t)
145 {
146     Vec2    v2 = {Vec2_id};
147     Vec3    v3 = {Vec3_id};
148 
149     v2 = ucbs2_eval(ucbs, t);
150     v3 = vec3(vec2_x(v2), vec2_y(v2), z_plane);
151     return (tv_proj3(tv, v3));
152 }
153 
154 void    ucbs2_draw_section3(Tv * tv, Ucbs2 * ucbs, double z, int i)
155 {
156     if (ucbs == NULL)
157         return;
158 
159     z_plane = z;
160     switch (ucbs->type)
161     {
162     case STRING:
163         if (i < 0 || i >= ucbs->n - 1)
164             return;
165         break;
166     case LOOP:
167         while (i < 0)
168             i += ucbs->n;
169         i %= ucbs->n;
170         break;
171     }
172     curve_draw(tv, ucbs2_proj3, (void *) ucbs, (double) i, i + 1.0);
173 }
174 
175 void    ucbs2_skeldraw_section3(Tv * tv, Ucbs2 * ucbs, double z, int i)
176 {
177     if (ucbs == NULL)
178         return;
179 
180     z_plane = z;
181     switch (ucbs->type)
182     {
183     case STRING:
184         if (i < 0 || i >= ucbs->n - 1)
185             return;
186         break;
187     case LOOP:
188         while (i < 0)
189             i += ucbs->n;
190         i %= ucbs->n;
191         break;
192     }
193     tv_line(tv, ucbs2_proj3(tv, ucbs, (double) i), ucbs2_proj3(tv, ucbs, i + 1.0));
194 }
195 
196 void    ucbs2_draw(Tv * tv, Ucbs2 * ucbs)
197 {
198     int     i;
199 
200     if (ucbs == NULL)
201         return;
202 
203     for (i = 0; i < ucbs->n; i++)
204         ucbs2_draw_section(tv, ucbs, i);
205 }
206 
207 void    ucbs2_draw3(Tv * tv, Ucbs2 * ucbs, double z)
208 {
209     int     i;
210 
211     if (ucbs == NULL)
212         return;
213 
214     for (i = 0; i < ucbs->n; i++)
215         ucbs2_draw_section3(tv, ucbs, z, i);
216 }
217 
218 void    ucbs2_skeldraw3(Tv * tv, Ucbs2 * ucbs, double z)
219 {
220     int     i;
221 
222     if (ucbs == NULL)
223         return;
224 
225     for (i = 0; i < ucbs->n; i++)
226         ucbs2_skeldraw_section3(tv, ucbs, z, i);
227 }
228 
229 void    ucbs2_draw_chunk(Tv * tv, Ucbs2 * ucbs, int i)
230 {
231     ucbs2_draw_ctrl(tv, ucbs, i - 1);
232     ucbs2_draw_ctrl(tv, ucbs, i);
233     ucbs2_draw_ctrl(tv, ucbs, i + 1);
234     ucbs2_draw_section(tv, ucbs, i - 3);
235     ucbs2_draw_section(tv, ucbs, i - 2);
236     ucbs2_draw_section(tv, ucbs, i - 1);
237     ucbs2_draw_section(tv, ucbs, i);
238 }
239 

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