Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
vpViewio.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 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 https://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 BEGIN_VISP_NAMESPACE
57 /*
58  * La procedure "fscanf_Remove" lit en ascii les parametres d'elimination
59  * des faces.
60  * Entree :
61  * bp Parametres a lire.
62  */
63 void fscanf_Remove(Byte *bp)
64 {
65  switch (lex()) {
66  case T_NONE:
67  *bp = IS_INSIDE;
68  break;
69  case T_ABOVE:
70  *bp |= IS_ABOVE;
71  break;
72  case T_BACK:
73  *bp |= IS_BACK;
74  break;
75  case T_BELOW:
76  *bp |= IS_BELOW;
77  break;
78  case T_FRONT:
79  *bp |= IS_FRONT;
80  break;
81  case T_LEFT:
82  *bp |= IS_LEFT;
83  break;
84  case T_RIGHT:
85  *bp |= IS_RIGHT;
86  break;
87  default:
88  lexerr("start", "remove: keyword "
89  "\"none|above|back|below|front|left|right\" expected");
90  break;
91  }
92 }
93 
94 /*
95  * La procedure "fscanf_View_parameters" lit en ascii les parametres
96  * de visualisation.
97  * Entree :
98  * vp Parametres de visualisation a lire.
99  */
100 void fscanf_View_parameters(View_parameters *vp)
101 {
102  /* Lecture du type de projection lors de la prise de vue. */
103 
104  skip_keyword(T_TYPE, "view: keyword \"type\" expected");
105  switch (lex()) {
106  case T_PARALLEL:
107  vp->type = PARALLEL;
108  break;
109  case T_PERSPECTIVE:
110  vp->type = PERSPECTIVE;
111  break;
112  default:
113  lexerr("start", "view_type: keyword \"parallel|perspective\" expected");
114  break;
115  }
116 
117  /* Lecture du centre de projection (oeil) de la prise de vue. */
118 
119  skip_keyword(T_COP, "view: keyword \"cop\" expected");
120  pusherr("view_cop: ");
121  fscanf_Point3f(&vp->cop);
122  poperr();
123 
124  /* Lecture du point de reference (cible) a la prise de vue. */
125 
126  skip_keyword(T_VRP, "view: keyword \"vrp\" expected");
127  pusherr("view_vrp: ");
128  fscanf_Point3f(&vp->vrp);
129  poperr();
130 
131  /* Lecture de la direction normale au plan de projection. */
132 
133  skip_keyword(T_VPN, "view: keyword \"vpn\" expected");
134  pusherr("view_vpn: ");
135  fscanf_Vector(&vp->vpn);
136  poperr();
137 
138  /* Lecture de la direction indiquant le haut de la projection. */
139 
140  skip_keyword(T_VUP, "view: keyword \"vup\" expected");
141  pusherr("view_vup: ");
142  fscanf_Vector(&vp->vup);
143  poperr();
144 
145  /* Lecture de la fenetre de projection de la prise de vue. */
146 
147  skip_keyword(T_WINDOW, "view: keyword \"window\" expected");
148  pusherr("view_window_umin: ");
149  fscanf_float(&vp->vwd.umin);
150  popuperr("view_window_umax: ");
151  fscanf_float(&vp->vwd.umax);
152  popuperr("view_window_vmin: ");
153  fscanf_float(&vp->vwd.vmin);
154  popuperr("view_window_vmax: ");
155  fscanf_float(&vp->vwd.vmax);
156  poperr();
157 
158  /* Lecture des profondeurs de decoupage avant et arriere. */
159 
160  skip_keyword(T_DEPTH, "view: keyword \"depth\" expected");
161  pusherr("view_depth_front: ");
162  fscanf_float(&vp->depth.front);
163  popuperr("view_depth_back: ");
164  fscanf_float(&vp->depth.back);
165  poperr();
166 }
167 END_VISP_NAMESPACE
168 #endif