Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

vp_renderC.c

Go to the documentation of this file.
00001 /*
00002  * vp_renderC.c
00003  *
00004  * Function to render classified volumes.
00005  *
00006  * Copyright (c) 1994 The Board of Trustees of The Leland Stanford
00007  * Junior University.  All rights reserved.
00008  *
00009  * Permission to use, copy, modify and distribute this software and its
00010  * documentation for any purpose is hereby granted without fee, provided
00011  * that the above copyright notice and this permission notice appear in
00012  * all copies of this software and that you do not sell the software.
00013  * Commercial licensing is available by contacting the author.
00014  * 
00015  * THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
00016  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
00017  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00018  *
00019  * Author:
00020  *    Phil Lacroute
00021  *    Computer Systems Laboratory
00022  *    Electrical Engineering Dept.
00023  *    Stanford University
00024  */
00025 
00026 /*
00027  * $Date: 2001/12/17 16:16:23 $
00028  * $Revision: 1.1 $
00029  */
00030 
00031 #include "vp_global.h"
00032 
00033 #define COMP_AC1PB_FUNC         VPCompAC1PB
00034 extern void VPCompAC1PB();
00035 
00036 #define COMP_AC3PB_FUNC         VPCompAC3PB
00037 extern void VPCompAC3PB();
00038 
00039 #ifdef COMP_AC11B
00040 #define COMP_AC11B_FUNC         VPCompAC11B
00041 extern void VPCompAC11B();
00042 #else
00043 #define COMP_AC11B_FUNC         VPCompAC1NB
00044 #endif
00045 
00046 #ifdef COMP_AC31B
00047 #define COMP_AC31B_FUNC         VPCompAC31B
00048 extern void VPCompAC31B();
00049 #else
00050 #define COMP_AC31B_FUNC         VPCompAC3NB
00051 #endif
00052 
00053 #ifdef COMP_AC12B
00054 #define COMP_AC12B_FUNC         VPCompAC12B
00055 extern void VPCompAC12B();
00056 #else
00057 #define COMP_AC12B_FUNC         VPCompAC1NB
00058 #endif
00059 
00060 #ifdef COMP_AC32B
00061 #define COMP_AC32B_FUNC         VPCompAC32B
00062 extern void VPCompAC32B();
00063 #else
00064 #define COMP_AC32B_FUNC         VPCompAC3NB
00065 #endif
00066 
00067 #define COMP_AC1NB_FUNC         VPCompAC1NB
00068 extern void VPCompAC1NB();
00069 
00070 #define COMP_AC3NB_FUNC         VPCompAC3NB
00071 extern void VPCompAC3NB();
00072 
00073 
00074 #define COMP_AC1PS_FUNC         VPCompAC1PB
00075 
00076 #define COMP_AC3PS_FUNC         VPCompAC3PB
00077 
00078 #ifdef COMP_AC11S
00079 #define COMP_AC11S_FUNC         VPCompAC11S
00080 extern void VPCompAC11S();
00081 #else
00082 #define COMP_AC11S_FUNC         VPCompAC1NS
00083 #endif
00084 
00085 #ifdef COMP_AC31S
00086 #define COMP_AC31S_FUNC         VPCompAC31S
00087 extern void VPCompAC31S();
00088 #else
00089 #define COMP_AC31S_FUNC         VPCompAC3NS
00090 #endif
00091 
00092 #ifdef COMP_AC12S
00093 #define COMP_AC12S_FUNC         VPCompAC12S
00094 extern void VPCompAC12S();
00095 #else
00096 #define COMP_AC12S_FUNC         VPCompAC1NS
00097 #endif
00098 
00099 #ifdef COMP_AC32S
00100 #define COMP_AC32S_FUNC         VPCompAC32S
00101 extern void VPCompAC32S();
00102 #else
00103 #define COMP_AC32S_FUNC         VPCompAC3NS
00104 #endif
00105 
00106 #define COMP_AC1NS_FUNC         VPCompAC1NS
00107 extern void VPCompAC1NS();
00108 
00109 #define COMP_AC3NS_FUNC         VPCompAC3NS
00110 extern void VPCompAC3NS();
00111 
00112 #ifdef INDEX_VOLUME
00113 extern void VPCompAI11B();
00114 #endif
00115 
00116 #define SHADOWS_OFF             0
00117 #define SHADOWS_ON              1
00118 #define SHADOW_OPTS             2
00119 
00120 #define MATERIAL_CALLBACK       0
00121 #define MATERIAL_ONE            1
00122 #define MATERIAL_TWO            2
00123 #define MATERIAL_MORE           3
00124 #define MATERIAL_OPTS           4
00125 
00126 #define COLOR_GRAY              0
00127 #define COLOR_RGB               1
00128 #define COLOR_OPTS              2
00129 
00130 static void (*AffineProcTable[SHADOW_OPTS][MATERIAL_OPTS][COLOR_OPTS])() = {
00131     {
00132         { COMP_AC1PB_FUNC, COMP_AC3PB_FUNC },
00133         { COMP_AC11B_FUNC, COMP_AC31B_FUNC },
00134         { COMP_AC12B_FUNC, COMP_AC32B_FUNC },
00135         { COMP_AC1NB_FUNC, COMP_AC3NB_FUNC }
00136     },
00137     {
00138         { COMP_AC1PS_FUNC, COMP_AC3PS_FUNC },
00139         { COMP_AC11S_FUNC, COMP_AC31S_FUNC },
00140         { COMP_AC12S_FUNC, COMP_AC32S_FUNC },
00141         { COMP_AC1NS_FUNC, COMP_AC3NS_FUNC }
00142     }
00143 };
00144 
00145 /*
00146  * vpRenderClassifiedVolume
00147  *
00148  * Render a classified, run-length encoded volume using the shear-warp
00149  * algorithm.
00150  */
00151 
00152 vpResult
00153 vpRenderClassifiedVolume(vpc)
00154 vpContext *vpc;
00155 {
00156     int retcode;
00157     void (*composite_func)();
00158     int shadow_option, material_option, color_option;
00159 #ifdef INDEX_VOLUME
00160     int have_index;
00161 #endif
00162 
00163     /* check for errors and initialize */
00164     if ((retcode = VPCheckShader(vpc)) != VP_OK)
00165         return(retcode);
00166     if ((retcode = VPFactorView(vpc)) != VP_OK)
00167         return(retcode);
00168     if ((retcode = VPCheckClassifiedVolume(vpc, vpc->best_view_axis)) != VP_OK)
00169         return(retcode);
00170     if ((retcode = VPCheckImage(vpc)) != VP_OK)
00171         return(retcode);
00172     if ((retcode = VPCheckShadows(vpc)) != VP_OK)
00173         return(retcode);
00174 
00175 #ifdef INDEX_VOLUME
00176     switch (vpc->best_view_axis) {
00177     case VP_X_AXIS:
00178         if (vpc->rle_x->voxel_index != NULL)
00179             have_index = 1;
00180         else
00181             have_index = 0;
00182         break;
00183     case VP_Y_AXIS:
00184         if (vpc->rle_y->voxel_index != NULL)
00185             have_index = 1;
00186         else
00187             have_index = 0;
00188         break;
00189     case VP_Z_AXIS:
00190         if (vpc->rle_z->voxel_index != NULL)
00191             have_index = 1;
00192         else
00193             have_index = 0;
00194         break;
00195     default:
00196         VPBug("invalid viewing axis in vpRenderClassifiedVolume");
00197     }
00198 #endif /* INDEX_VOLUME */
00199 
00200     Debug((vpc, VPDEBUG_RENDER, "Algorithm: affine RLEvolume\n"));
00201 
00202     /* determine which options are enabled */
00203     if (vpc->enable_shadows)
00204         shadow_option = SHADOWS_ON;
00205     else
00206         shadow_option = SHADOWS_OFF;
00207     if (vpc->shading_mode == CALLBACK_SHADER)
00208         material_option = MATERIAL_CALLBACK;
00209     else if (vpc->num_materials == 1)
00210         material_option = MATERIAL_ONE;
00211     else if (vpc->num_materials == 2)
00212         material_option = MATERIAL_TWO;
00213     else
00214         material_option = MATERIAL_MORE;
00215     if (vpc->color_channels == 1)
00216         color_option = COLOR_GRAY;
00217     else
00218         color_option = COLOR_RGB;
00219 
00220     /* render */
00221     if (vpc->affine_view) {
00222         /* choose a compositing function */
00223         composite_func = AffineProcTable[shadow_option][material_option]
00224                                         [color_option];
00225 #ifdef INDEX_VOLUME
00226         if (have_index && shadow_option == SHADOWS_OFF &&
00227             material_option == MATERIAL_ONE && color_option == COLOR_GRAY) {
00228             composite_func = VPCompAI11B;
00229         }
00230 #endif
00231         VPRenderAffine(vpc, USE_RLEVOLUME, composite_func);
00232     } else {
00233         /* XXX perspective rendering not available yet */
00234         return(VPSetError(vpc, VPERROR_BAD_OPTION));
00235     }
00236 
00237     return(VP_OK);
00238 }
 

Powered by Plone

This site conforms to the following standards: