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