1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
/*
* vp_renderR.c
*
* Function to render raw (unclassified) volumes.
*
* Copyright (c) 1994 The Board of Trustees of The Leland Stanford
* Junior University. All rights reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice and this permission notice appear in
* all copies of this software and that you do not sell the software.
* Commercial licensing is available by contacting the author.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* Author:
* Phil Lacroute
* Computer Systems Laboratory
* Electrical Engineering Dept.
* Stanford University
*/
/*
* $Date: 1994/12/30 23:52:38 $
* $Revision: 1.23 $
*/
#include "vp_global.h"
#define COMP_AR1PB_FUNC VPCompAR1PB
extern void VPCompAR1PB();
#define COMP_AR3PB_FUNC VPCompAR3PB
extern void VPCompAR3PB();
#ifdef COMP_AR11B
#define COMP_AR11B_FUNC VPCompAR11B
extern void VPCompAR11B();
#else
#define COMP_AR11B_FUNC VPCompAR1NB
#endif
#ifdef COMP_AR31B
#define COMP_AR31B_FUNC VPCompAR31B
extern void VPCompAR31B();
#else
#define COMP_AR31B_FUNC VPCompAR3NB
#endif
#ifdef COMP_AR12B
#define COMP_AR12B_FUNC VPCompAR12B
extern void VPCompAR12B();
#else
#define COMP_AR12B_FUNC VPCompAR1NB
#endif
#ifdef COMP_AR32B
#define COMP_AR32B_FUNC VPCompAR32B
extern void VPCompAR32B();
#else
#define COMP_AR32B_FUNC VPCompAR3NB
#endif
#define COMP_AR1NB_FUNC VPCompAR1NB
extern void VPCompAR1NB();
#define COMP_AR3NB_FUNC VPCompAR3NB
extern void VPCompAR3NB();
#define COMP_AR1PS_FUNC VPCompAR1PB
#define COMP_AR3PS_FUNC VPCompAR3PB
#ifdef COMP_AR11S
#define COMP_AR11S_FUNC VPCompAR11S
extern void VPCompAR11S();
#else
#define COMP_AR11S_FUNC VPCompAR1NS
#endif
#ifdef COMP_AR31S
#define COMP_AR31S_FUNC VPCompAR31S
extern void VPCompAR31S();
#else
#define COMP_AR31S_FUNC VPCompAR3NS
#endif
#ifdef COMP_AR12S
#define COMP_AR12S_FUNC VPCompAR12S
extern void VPCompAR12S();
#else
#define COMP_AR12S_FUNC VPCompAR1NS
#endif
#ifdef COMP_AR32S
#define COMP_AR32S_FUNC VPCompAR32S
extern void VPCompAR32S();
#else
#define COMP_AR32S_FUNC VPCompAR3NS
#endif
#define COMP_AR1NS_FUNC VPCompAR1NS
extern void VPCompAR1NS();
#define COMP_AR3NS_FUNC VPCompAR3NS
extern void VPCompAR3NS();
#ifdef INDEX_VOLUME
extern void VPCompAI11B();
#endif
#define SHADOWS_OFF 0
#define SHADOWS_ON 1
#define SHADOW_OPTS 2
#define MATERIAL_CALLBACK 0
#define MATERIAL_ONE 1
#define MATERIAL_TWO 2
#define MATERIAL_MORE 3
#define MATERIAL_OPTS 4
#define COLOR_GRAY 0
#define COLOR_RGB 1
#define COLOR_OPTS 2
static void (*AffineProcTable[SHADOW_OPTS][MATERIAL_OPTS][COLOR_OPTS])() = {
{
{ COMP_AR1PB_FUNC, COMP_AR3PB_FUNC },
{ COMP_AR11B_FUNC, COMP_AR31B_FUNC },
{ COMP_AR12B_FUNC, COMP_AR32B_FUNC },
{ COMP_AR1NB_FUNC, COMP_AR3NB_FUNC }
},
{
{ COMP_AR1PS_FUNC, COMP_AR3PS_FUNC },
{ COMP_AR11S_FUNC, COMP_AR31S_FUNC },
{ COMP_AR12S_FUNC, COMP_AR32S_FUNC },
{ COMP_AR1NS_FUNC, COMP_AR3NS_FUNC }
}
};
/*
* vpRenderRawVolume
*
* Render an uclassified volume using the shear-warp algorithm.
*/
vpResult
vpRenderRawVolume(vpc)
vpContext *vpc;
{
int retcode;
void (*composite_func)();
int shadow_option, material_option, color_option;
/* check for errors and initialize */
if ((retcode = VPCheckRawVolume(vpc)) != VP_OK)
return(retcode);
if ((retcode = VPCheckClassifier(vpc)) != VP_OK)
return(retcode);
if ((retcode = VPCheckShader(vpc)) != VP_OK)
return(retcode);
if ((retcode = VPCheckImage(vpc)) != VP_OK)
return(retcode);
if (vpc->num_clsfy_params > 2)
return(VPSetError(vpc, VPERROR_LIMIT_EXCEEDED));
if ((retcode = VPFactorView(vpc)) != VP_OK)
return(retcode);
Debug((vpc, VPDEBUG_RENDER, "Algorithm: affine RAWvolume (%s)\n",
vpc->mm_octree == NULL ? "no octree" : "with octree"));
/* determine which options are enabled */
if (vpc->enable_shadows)
shadow_option = SHADOWS_ON;
else
shadow_option = SHADOWS_OFF;
if (vpc->shading_mode == CALLBACK_SHADER)
material_option = MATERIAL_CALLBACK;
else if (vpc->num_materials == 1)
material_option = MATERIAL_ONE;
else if (vpc->num_materials == 2)
material_option = MATERIAL_TWO;
else
material_option = MATERIAL_MORE;
if (vpc->color_channels == 1)
color_option = COLOR_GRAY;
else
color_option = COLOR_RGB;
/* render */
if (vpc->affine_view) {
/* choose a compositing function */
composite_func = AffineProcTable[shadow_option][material_option]
[color_option];
VPRenderAffine(vpc, USE_RAWVOLUME, composite_func);
} else {
/* XXX perspective rendering not available yet */
return(VPSetError(vpc, VPERROR_BAD_OPTION));
}
return(VP_OK);
}
|