Visual Servoing Platform  version 3.4.0
vpViewio.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Le module "viewio.c" contient les procedures d'entree/sortie
33  * des types definis dans le module "view.h".
34  * Les entrees non specifiees sont effectuees
35  * sur le fichier source de "lex.c".
36  * Pour les mots cles des "fprintf_..." voir "token.c".
37  *
38  * Authors:
39  * Jean-Luc CORRE
40  *
41  *****************************************************************************/
42 
43 #include <visp3/core/vpConfig.h>
44 
45 #ifndef DOXYGEN_SHOULD_SKIP_THIS
46 
47 #include <stdio.h>
48 
49 #include "vpArit.h"
50 #include "vpLex.h"
51 #include "vpMyio.h"
52 #include "vpSkipio.h"
53 #include "vpToken.h"
54 #include "vpViewio.h"
55 
56 /*
57  * La procedure "fscanf_Remove" lit en ascii les parametres d'elimination
58  * des faces.
59  * Entree :
60  * bp Parametres a lire.
61  */
62 void fscanf_Remove(Byte *bp)
63 {
64  switch (lex()) {
65  case T_NONE:
66  *bp = IS_INSIDE;
67  break;
68  case T_ABOVE:
69  *bp |= IS_ABOVE;
70  break;
71  case T_BACK:
72  *bp |= IS_BACK;
73  break;
74  case T_BELOW:
75  *bp |= IS_BELOW;
76  break;
77  case T_FRONT:
78  *bp |= IS_FRONT;
79  break;
80  case T_LEFT:
81  *bp |= IS_LEFT;
82  break;
83  case T_RIGHT:
84  *bp |= IS_RIGHT;
85  break;
86  default:
87  lexerr("start", "remove: keyword "
88  "\"none|above|back|below|front|left|right\" expected");
89  break;
90  }
91 }
92 
93 /*
94  * La procedure "fscanf_View_parameters" lit en ascii les parametres
95  * de visualisation.
96  * Entree :
97  * vp Parametres de visualisation a lire.
98  */
99 void fscanf_View_parameters(View_parameters *vp)
100 {
101  /* Lecture du type de projection lors de la prise de vue. */
102 
103  skip_keyword(T_TYPE, "view: keyword \"type\" expected");
104  switch (lex()) {
105  case T_PARALLEL:
106  vp->type = PARALLEL;
107  break;
108  case T_PERSPECTIVE:
109  vp->type = PERSPECTIVE;
110  break;
111  default:
112  lexerr("start", "view_type: keyword \"parallel|perspective\" expected");
113  break;
114  }
115 
116  /* Lecture du centre de projection (oeil) de la prise de vue. */
117 
118  skip_keyword(T_COP, "view: keyword \"cop\" expected");
119  pusherr("view_cop: ");
120  fscanf_Point3f(&vp->cop);
121  poperr();
122 
123  /* Lecture du point de reference (cible) a la prise de vue. */
124 
125  skip_keyword(T_VRP, "view: keyword \"vrp\" expected");
126  pusherr("view_vrp: ");
127  fscanf_Point3f(&vp->vrp);
128  poperr();
129 
130  /* Lecture de la direction normale au plan de projection. */
131 
132  skip_keyword(T_VPN, "view: keyword \"vpn\" expected");
133  pusherr("view_vpn: ");
134  fscanf_Vector(&vp->vpn);
135  poperr();
136 
137  /* Lecture de la direction indiquant le haut de la projection. */
138 
139  skip_keyword(T_VUP, "view: keyword \"vup\" expected");
140  pusherr("view_vup: ");
141  fscanf_Vector(&vp->vup);
142  poperr();
143 
144  /* Lecture de la fenetre de projection de la prise de vue. */
145 
146  skip_keyword(T_WINDOW, "view: keyword \"window\" expected");
147  pusherr("view_window_umin: ");
148  fscanf_float(&vp->vwd.umin);
149  popuperr("view_window_umax: ");
150  fscanf_float(&vp->vwd.umax);
151  popuperr("view_window_vmin: ");
152  fscanf_float(&vp->vwd.vmin);
153  popuperr("view_window_vmax: ");
154  fscanf_float(&vp->vwd.vmax);
155  poperr();
156 
157  /* Lecture des profondeurs de decoupage avant et arriere. */
158 
159  skip_keyword(T_DEPTH, "view: keyword \"depth\" expected");
160  pusherr("view_depth_front: ");
161  fscanf_float(&vp->depth.front);
162  popuperr("view_depth_back: ");
163  fscanf_float(&vp->depth.back);
164  poperr();
165 }
166 
167 #endif