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

Linux Cross Reference
Tina5/tina-libs/tina/medical/medStim_calcs.c

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

  1 /**********
  2  *
  3  * This file is part of the TINA Open Source Image Analysis Environment
  4  * henceforth known as TINA
  5  *
  6  * TINA is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU Lesser General Public License as
  8  * published by the Free Software Foundation.
  9  *
 10  * TINA is distributed in the hope that it will be useful,
 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  * GNU Lesser General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU Lesser General Public License
 16  * along with TINA; if not, write to the Free Software Foundation, Inc.,
 17  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  *
 19  **********
 20  *
 21  * Program :    TINA
 22  * File    :  $Source: /home/tina/cvs/tina-libs/tina/medical/medStim_calcs.c,v $
 23  * Date    :  $Date: 2004/12/06 22:05:08 $
 24  * Version :  $Revision: 1.5 $
 25  * CVS Id  :  $Id: medStim_calcs.c,v 1.5 2004/12/06 22:05:08 paul Exp $
 26  *
 27  * Notes:
 28  *
 29  *********
 30 */
 31 
 32 #if HAVE_CONFIG_H
 33 #   include <config.h>
 34 #endif
 35 
 36 #include "medStim_calcs.h"
 37 
 38 #include <stdio.h>
 39 #include <math.h>
 40 #include <tina/sys/sysDef.h>
 41 #include <tina/sys/sysPro.h>
 42 #include <tina/math/mathDef.h>
 43 #include <tina/math/mathPro.h>
 44 #include <tina/image/imgDef.h>
 45 #include <tina/medical/med_StimDef.h>
 46 #include <tina/medical/medStim_alloc.h>
 47 
 48 #define MAX_TRAPITS 20
 49 #define FUNC(x)  ((*func)(x))
 50 
 51 
 52 static void    pl_int_minmax_y1(Pl_flow *p)
 53 {
 54   int   i;
 55 
 56   if (p == NULL) return;
 57 
 58   p->y1_max = fabs((double)p->y1[p->y1_n1]);
 59   p->y1_min = fabs((double)p->y1[p->y1_n1]);
 60   p->y1_max_t = (float)p->y1_n1;
 61   p->y1_min_t = (float)p->y1_n1;
 62 
 63   for (i = p->y1_n1+1; i < p->y1_n2; i++)
 64     {
 65       if (fabs((double)p->y1[i]) > p->y1_max)
 66         {
 67           p->y1_max = fabs((double)p->y1[i]);
 68           p->y1_max_t = (float)i;
 69         }
 70      if (fabs((double)p->y1[i]) < p->y1_min)
 71         {
 72           p->y1_min = fabs((double)p->y1[i]);
 73           p->y1_min_t = (float)i;
 74         }
 75     }     
 76 }
 77 
 78 /* Static but not being used: comment out for now */
 79 /*
 80 static void    pl_int_diffmax_y1(Pl_flow *p)
 81 {
 82   int   i;
 83 
 84   if (p == NULL) return;
 85 
 86   p->y1_diff_max = p->y1[p->y1_n1+1] - p->y1[p->y1_n1];
 87   p->y1_diff_max_t = p->y1_n1 + 0.5;
 88   
 89   for (i = p->y1_n1+1; i <= p->y1_n2; i++)
 90     {
 91       if ((p->y1[i] - p->y1[i-1]) > p->y1_diff_max)
 92         {
 93           p->y1_diff_max = p->y1[i] - p->y1[i-1];
 94           p->y1_diff_max_t = i - 0.5;
 95         }
 96      }          
 97 }
 98 */
 99 
100 static void  pl_area_y1(Pl_flow *p)
101 {
102   float     y, area;
103   float     ya, yb, yn, ym;
104   int       x;
105   
106   area = 0.0;
107   for (x = p->x_n1; x < (p->x_n2 - 1); x++)
108     {
109       ya = p->y1[x];
110       yb = p->y1[x+1];
111       
112       if ((ya > 0.0 && yb < 0.0) || (ya < 0.0 && yb > 0.0))
113         {
114           yn = fabs((double)(ya/2.0));
115           ym = fabs((double)(yb/2.0));
116           y = yn + ym;
117         }
118       else
119         y = fabs((double)(ya + yb)/2.0);
120       y *= (p->x[x+1]-p->x[x]);
121       area += y;
122     }
123  
124   p->y1_area = area;
125 
126   return;
127 
128 }
129 
130 
131 void    pl_measures(void)
132 {
133   Pl_flow  *plot_data = (Pl_flow *)get_pl_flow();
134 
135   if (plot_data == NULL)
136     return;
137 
138   pl_int_minmax_y1(plot_data);
139   pl_area_y1(plot_data);
140 }
141 

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