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