39 #include <visp3/core/vpConfig.h>
41 #ifndef DOXYGEN_SHOULD_SKIP_THIS
52 #include "vpVwstack.h"
58 static View_parameters stack[STACKSIZE]= { vpDEFAULT_VIEW };
59 static View_parameters *sp = stack;
70 fprintf_vwstack (FILE *fp,
char *argv)
72 if (argv == NULL || strcmp (argv,
"type") == 0) {
80 typetoa =
"perspective";
86 fprintf (fp,
"(type\t%s)\n", typetoa);
87 if (argv != NULL)
return;
89 if (argv == NULL || strcmp (argv,
"cop") == 0) {
90 fprintf (fp,
"(cop\t%.3f\t%.3f\t%.3f)\n",
91 sp->cop.x, sp->cop.y, sp->cop.z);
92 if (argv != NULL)
return;
94 if (argv == NULL || strcmp (argv,
"vrp") == 0) {
95 fprintf (fp,
"(vrp\t%.3f\t%.3f\t%.3f)\n",
96 sp->vrp.x, sp->vrp.y, sp->vrp.z);
97 if (argv != NULL)
return;
99 if (argv == NULL || strcmp (argv,
"vpn") == 0) {
100 fprintf (fp,
"(vpn\t%.3f\t%.3f\t%.3f)\n",
101 sp->vpn.x, sp->vpn.y, sp->vpn.z);
102 if (argv != NULL)
return;
104 if (argv == NULL || strcmp (argv,
"vup") == 0) {
105 fprintf (fp,
"(vup\t%.3f\t%.3f\t%.3f)\n",
106 sp->vup.x, sp->vup.y, sp->vup.z);
107 if (argv != NULL)
return;
109 if (argv == NULL || strcmp (argv,
"window") == 0) {
110 fprintf (fp,
"(window\t%.3f\t%.3f\t%.3f\t%.3f)\n",
111 sp->vwd.umin,sp->vwd.umax,sp->vwd.vmin,sp->vwd.vmax);
112 if (argv != NULL)
return;
114 if (argv == NULL || strcmp (argv,
"depth") == 0) {
115 fprintf (fp,
"(depth\t%.3f\t%.3f)\n",
116 sp->depth.front, sp->depth.back);
117 if (argv != NULL)
return;
120 static char proc_name[] =
"fprintf_vwstack";
121 fprintf (stderr,
"%s: argument unknown\n", proc_name);
144 load_vwstack (View_parameters *vp)
157 static char proc_name[] =
"pop_vwstack";
158 fprintf (stderr,
"%s: stack underflow\n", proc_name);
171 if (sp == stack + STACKSIZE - 1) {
172 static char proc_name[] =
"push_vwstack";
173 fprintf (stderr,
"%s: stack overflow\n", proc_name);
187 View_parameters *vp, tmp;
189 vp = (sp == stack) ? sp + 1 : sp - 1;
201 add_vwstack (
const char* path, ... )
209 argv = va_arg (ap,
char *);
210 if (strcmp (argv,
"cop") == 0) {
213 (
float) va_arg (ap,
double),
214 (
float) va_arg (ap,
double),
215 (
float) va_arg (ap,
double));
217 else if (strcmp (argv,
"depth") == 0) {
219 sp->depth.front = (float) va_arg (ap,
double);
220 sp->depth.back = (float) va_arg (ap,
double);
222 else if (strcmp (argv,
"type") == 0) {
224 sp->type = (Type) va_arg (ap,
int);
226 else if (strcmp (argv,
"vpn") == 0) {
228 float x = (float) va_arg (ap,
double);
229 float y = (float) va_arg (ap,
double);
230 float z = (float) va_arg (ap,
double);
233 if (std::fabs(x) <= std::numeric_limits<double>::epsilon() && std::fabs(y) <= std::numeric_limits<double>::epsilon() && std::fabs(z) <= std::numeric_limits<double>::epsilon()) {
234 static char proc_name[] =
"add_vwstack";
235 fprintf (stderr,
"%s: bad vpn\n", proc_name);
238 SET_COORD3(sp->vpn,x,y,z);
241 else if (strcmp (argv,
"vrp") == 0) {
244 (
float) va_arg (ap,
double),
245 (
float) va_arg (ap,
double),
246 (
float) va_arg (ap,
double));
248 else if (strcmp (argv,
"vup") == 0) {
250 float x = (float) va_arg (ap,
double);
251 float y = (float) va_arg (ap,
double);
252 float z = (float) va_arg (ap,
double);
255 if (std::fabs(x) <= std::numeric_limits<double>::epsilon() && std::fabs(y) <= std::numeric_limits<double>::epsilon() && std::fabs(z) <= std::numeric_limits<double>::epsilon()) {
256 static char proc_name[] =
"add_vwstack";
257 fprintf (stderr,
"%s: bad vup\n", proc_name);
260 SET_COORD3(sp->vup,x,y,z);
263 else if (strcmp (argv,
"window") == 0) {
265 sp->vwd.umin = (float) va_arg (ap,
double);
266 sp->vwd.umax = (float) va_arg (ap,
double);
267 sp->vwd.vmin = (float) va_arg (ap,
double);
268 sp->vwd.vmax = (float) va_arg (ap,
double);
271 static char proc_name[] =
"add_vwstack";
272 fprintf (stderr,
"%s: bad argument\n", proc_name);