40 #include <visp3/core/vpConfig.h>
42 #ifndef DOXYGEN_SHOULD_SKIP_THIS
53 #include "vpVwstack.h"
58 static View_parameters stack[STACKSIZE] = { vpDEFAULT_VIEW };
59 static View_parameters *sp = stack;
69 void fprintf_vwstack(FILE *fp,
char *argv)
71 if (argv == NULL || strcmp(argv,
"type") == 0) {
79 typetoa =
"perspective";
85 fprintf(fp,
"(type\t%s)\n", typetoa);
89 if (argv == NULL || strcmp(argv,
"cop") == 0) {
90 fprintf(fp,
"(cop\t%.3f\t%.3f\t%.3f)\n", sp->cop.x, sp->cop.y, sp->cop.z);
94 if (argv == NULL || strcmp(argv,
"vrp") == 0) {
95 fprintf(fp,
"(vrp\t%.3f\t%.3f\t%.3f)\n", sp->vrp.x, sp->vrp.y, sp->vrp.z);
99 if (argv == NULL || strcmp(argv,
"vpn") == 0) {
100 fprintf(fp,
"(vpn\t%.3f\t%.3f\t%.3f)\n", sp->vpn.x, sp->vpn.y, sp->vpn.z);
104 if (argv == NULL || strcmp(argv,
"vup") == 0) {
105 fprintf(fp,
"(vup\t%.3f\t%.3f\t%.3f)\n", sp->vup.x, sp->vup.y, sp->vup.z);
109 if (argv == NULL || strcmp(argv,
"window") == 0) {
110 fprintf(fp,
"(window\t%.3f\t%.3f\t%.3f\t%.3f)\n", sp->vwd.umin, sp->vwd.umax, sp->vwd.vmin, sp->vwd.vmax);
114 if (argv == NULL || strcmp(argv,
"depth") == 0) {
115 fprintf(fp,
"(depth\t%.3f\t%.3f)\n", sp->depth.front, sp->depth.back);
120 static char proc_name[] =
"fprintf_vwstack";
121 fprintf(stderr,
"%s: argument unknown\n", proc_name);
131 View_parameters *get_vwstack(
void) {
return (sp); }
139 void load_vwstack(View_parameters *vp) { *sp = *vp; }
145 void pop_vwstack(
void)
148 static char proc_name[] =
"pop_vwstack";
149 fprintf(stderr,
"%s: stack underflow\n", proc_name);
160 void push_vwstack(
void)
162 if (sp == stack + STACKSIZE - 1) {
163 static char proc_name[] =
"push_vwstack";
164 fprintf(stderr,
"%s: stack overflow\n", proc_name);
175 void swap_vwstack(
void)
177 View_parameters *vp, tmp;
179 vp = (sp == stack) ? sp + 1 : sp - 1;
190 void add_vwstack(
const char *path, ...)
198 argv = va_arg(ap,
char *);
199 if (strcmp(argv,
"cop") == 0) {
201 SET_COORD3(sp->cop, (
float)va_arg(ap,
double), (
float)va_arg(ap,
double), (
float)va_arg(ap,
double));
203 else if (strcmp(argv,
"depth") == 0) {
205 sp->depth.front = (float)va_arg(ap,
double);
206 sp->depth.back = (float)va_arg(ap,
double);
208 else if (strcmp(argv,
"type") == 0) {
210 sp->type = (Type)va_arg(ap,
int);
212 else if (strcmp(argv,
"vpn") == 0) {
214 float x = (float)va_arg(ap,
double);
215 float y = (float)va_arg(ap,
double);
216 float z = (float)va_arg(ap,
double);
219 if (std::fabs(x) <= std::numeric_limits<double>::epsilon() &&
220 std::fabs(y) <= std::numeric_limits<double>::epsilon() &&
221 std::fabs(z) <= std::numeric_limits<double>::epsilon()) {
222 static char proc_name[] =
"add_vwstack";
223 fprintf(stderr,
"%s: bad vpn\n", proc_name);
226 SET_COORD3(sp->vpn, x, y, z);
229 else if (strcmp(argv,
"vrp") == 0) {
231 SET_COORD3(sp->vrp, (
float)va_arg(ap,
double), (
float)va_arg(ap,
double), (
float)va_arg(ap,
double));
233 else if (strcmp(argv,
"vup") == 0) {
235 float x = (float)va_arg(ap,
double);
236 float y = (float)va_arg(ap,
double);
237 float z = (float)va_arg(ap,
double);
240 if (std::fabs(x) <= std::numeric_limits<double>::epsilon() &&
241 std::fabs(y) <= std::numeric_limits<double>::epsilon() &&
242 std::fabs(z) <= std::numeric_limits<double>::epsilon()) {
243 static char proc_name[] =
"add_vwstack";
244 fprintf(stderr,
"%s: bad vup\n", proc_name);
247 SET_COORD3(sp->vup, x, y, z);
250 else if (strcmp(argv,
"window") == 0) {
252 sp->vwd.umin = (float)va_arg(ap,
double);
253 sp->vwd.umax = (float)va_arg(ap,
double);
254 sp->vwd.vmin = (float)va_arg(ap,
double);
255 sp->vwd.vmax = (float)va_arg(ap,
double);
258 static char proc_name[] =
"add_vwstack";
259 fprintf(stderr,
"%s: bad argument\n", proc_name);