40 #include <visp3/core/vpConfig.h> 42 #ifndef DOXYGEN_SHOULD_SKIP_THIS 53 #include "vpVwstack.h" 57 static View_parameters stack[STACKSIZE] = {vpDEFAULT_VIEW};
58 static View_parameters *sp = stack;
68 void fprintf_vwstack(FILE *fp,
char *argv)
70 if (argv == NULL || strcmp(argv,
"type") == 0) {
78 typetoa =
"perspective";
84 fprintf(fp,
"(type\t%s)\n", typetoa);
88 if (argv == NULL || strcmp(argv,
"cop") == 0) {
89 fprintf(fp,
"(cop\t%.3f\t%.3f\t%.3f)\n", sp->cop.x, sp->cop.y, sp->cop.z);
93 if (argv == NULL || strcmp(argv,
"vrp") == 0) {
94 fprintf(fp,
"(vrp\t%.3f\t%.3f\t%.3f)\n", sp->vrp.x, sp->vrp.y, sp->vrp.z);
98 if (argv == NULL || strcmp(argv,
"vpn") == 0) {
99 fprintf(fp,
"(vpn\t%.3f\t%.3f\t%.3f)\n", sp->vpn.x, sp->vpn.y, sp->vpn.z);
103 if (argv == NULL || strcmp(argv,
"vup") == 0) {
104 fprintf(fp,
"(vup\t%.3f\t%.3f\t%.3f)\n", sp->vup.x, sp->vup.y, sp->vup.z);
108 if (argv == NULL || strcmp(argv,
"window") == 0) {
109 fprintf(fp,
"(window\t%.3f\t%.3f\t%.3f\t%.3f)\n", sp->vwd.umin, sp->vwd.umax, sp->vwd.vmin, sp->vwd.vmax);
113 if (argv == NULL || strcmp(argv,
"depth") == 0) {
114 fprintf(fp,
"(depth\t%.3f\t%.3f)\n", sp->depth.front, sp->depth.back);
119 static char proc_name[] =
"fprintf_vwstack";
120 fprintf(stderr,
"%s: argument unknown\n", proc_name);
130 View_parameters *get_vwstack(
void) {
return (sp); }
138 void load_vwstack(View_parameters *
vp) { *sp = *vp; }
144 void pop_vwstack(
void)
147 static char proc_name[] =
"pop_vwstack";
148 fprintf(stderr,
"%s: stack underflow\n", proc_name);
158 void push_vwstack(
void)
160 if (sp == stack + STACKSIZE - 1) {
161 static char proc_name[] =
"push_vwstack";
162 fprintf(stderr,
"%s: stack overflow\n", proc_name);
173 void swap_vwstack(
void)
175 View_parameters *
vp, tmp;
177 vp = (sp == stack) ? sp + 1 : sp - 1;
188 void add_vwstack(
const char *path, ...)
196 argv = va_arg(ap,
char *);
197 if (strcmp(argv,
"cop") == 0) {
199 SET_COORD3(sp->cop, (
float)va_arg(ap,
double), (
float)va_arg(ap,
double), (
float)va_arg(ap,
double));
200 }
else if (strcmp(argv,
"depth") == 0) {
202 sp->depth.front = (float)va_arg(ap,
double);
203 sp->depth.back = (float)va_arg(ap,
double);
204 }
else if (strcmp(argv,
"type") == 0) {
206 sp->type = (Type)va_arg(ap,
int);
207 }
else if (strcmp(argv,
"vpn") == 0) {
209 float x = (float)va_arg(ap,
double);
210 float y = (float)va_arg(ap,
double);
211 float z = (float)va_arg(ap,
double);
214 if (std::fabs(x) <= std::numeric_limits<double>::epsilon() &&
215 std::fabs(y) <= std::numeric_limits<double>::epsilon() &&
216 std::fabs(z) <= std::numeric_limits<double>::epsilon()) {
217 static char proc_name[] =
"add_vwstack";
218 fprintf(stderr,
"%s: bad vpn\n", proc_name);
220 SET_COORD3(sp->vpn, x, y, z);
222 }
else if (strcmp(argv,
"vrp") == 0) {
224 SET_COORD3(sp->vrp, (
float)va_arg(ap,
double), (
float)va_arg(ap,
double), (
float)va_arg(ap,
double));
225 }
else if (strcmp(argv,
"vup") == 0) {
227 float x = (float)va_arg(ap,
double);
228 float y = (float)va_arg(ap,
double);
229 float z = (float)va_arg(ap,
double);
232 if (std::fabs(x) <= std::numeric_limits<double>::epsilon() &&
233 std::fabs(y) <= std::numeric_limits<double>::epsilon() &&
234 std::fabs(z) <= std::numeric_limits<double>::epsilon()) {
235 static char proc_name[] =
"add_vwstack";
236 fprintf(stderr,
"%s: bad vup\n", proc_name);
238 SET_COORD3(sp->vup, x, y, z);
240 }
else if (strcmp(argv,
"window") == 0) {
242 sp->vwd.umin = (float)va_arg(ap,
double);
243 sp->vwd.umax = (float)va_arg(ap,
double);
244 sp->vwd.vmin = (float)va_arg(ap,
double);
245 sp->vwd.vmax = (float)va_arg(ap,
double);
247 static char proc_name[] =
"add_vwstack";
248 fprintf(stderr,
"%s: bad argument\n", proc_name);