ViSP
vpAritio.cpp
1 /****************************************************************************
2  *
3  * $Id: vpAritio.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 "aritio.c" contient les procedures d'entree/sortie
35  * des types definis dans le module "arit.h".
36  * Les entrees non specifiees sont effectuees
37  * sur le fichier "source" du module "lex.c".
38  * Pour les mots cles des "fprintf_..." voir "token.c".
39  *
40  * Authors:
41  * Jean-Luc CORRE
42  *
43  *****************************************************************************/
44 
45 
46 
47 #include "visp/vpConfig.h"
48 
49 #ifndef DOXYGEN_SHOULD_SKIP_THIS
50 #include <visp/vpMy.h>
51 #include <visp/vpArit.h>
52 #include <visp/vpToken.h>
53 #include <visp/vpLex.h>
54 
55 #include <stdio.h>
56 /*
57  * La procedure "fprintf_Position" ecrit en ascii un positionnement.
58  * Entree :
59  * f Fichier en sortie.
60  * pp Positionnement a ecrite.
61  */
62 void fprintf_Position (FILE *f, AritPosition *pp)
63 {
64  fprintf (f, "%.3f\t%.3f\t%.3f\n%.3f\t%.3f\t%.3f\n%.3f\t%.3f\t%.3f\n",
65  pp->rotate.x, pp->rotate.y, pp->rotate.z,
66  pp->scale.x, pp->scale.y, pp->scale.z,
67  pp->translate.x, pp->translate.y, pp->translate.z);
68 }
69 
70 /*
71  * La procedure "fscanf_Point3f" lit en ascii un point flottant 3D.
72  * Entree :
73  * pp Point flottant 3D a lire.
74  */
75 void fscanf_Point3f (Point3f *pp)
76 {
77 static const char *err_tbl[] = {
78 "float expected (coordinate ",
79 " of point)"
80 };
81  int t;
82 
83  /* Lecture de la premiere coordonnee du point. */
84 
85  if ((t = lex ()) != T_FLOAT && t != T_INT)
86  lexerr ("start",err_tbl[0], "X", err_tbl[1], NULL);
87  pp->x = (t == T_INT) ? (float) myint : myfloat;
88 
89  /* Lecture de la seconde coordonnee du point. */
90 
91  if ((t= lex ()) != T_FLOAT && t != T_INT)
92  lexerr ("start",err_tbl[0], "Y", err_tbl[1], NULL);
93  pp->y = (t == T_INT) ? (float) myint : myfloat;
94 
95  /* Lecture de la troisieme coordonnee du point. */
96 
97  if ((t= lex ()) != T_FLOAT && t != T_INT)
98  lexerr ("start",err_tbl[0], "Z", err_tbl[1], NULL);
99  pp->z = (t == T_INT) ? (float) myint : myfloat;
100 }
101 
102 /*
103  * La procedure "fscanf_Vector" lit en ascii un vecteur.
104  * Entree :
105  * vp Vecteur a lire.
106  */
107 void fscanf_Vector (Vector *vp)
108 {
109 static const char *err_tbl[] = {
110 "float expected (coordinate ",
111 " of vector)"
112 };
113 
114  int t;
115 
116  /* Lecture de la premiere coordonnee du vecteur. */
117 
118  if ((t= lex ()) != T_FLOAT && t != T_INT)
119  lexerr ("start",err_tbl[0], "X", err_tbl[1], NULL);
120  vp->x = (t == T_INT) ? (float) myint : myfloat;
121 
122  /* Lecture de la seconde coordonnee du vecteur. */
123 
124  if ((t= lex ()) != T_FLOAT && t != T_INT)
125  lexerr ("start",err_tbl[0], "Y", err_tbl[1], NULL);
126  vp->y = (t == T_INT) ? (float) myint : myfloat;
127 
128  /* Lecture de la troisieme coordonnee du vecteur. */
129 
130  if ((t= lex ()) != T_FLOAT && t != T_INT)
131  lexerr ("start",err_tbl[0], "Z", err_tbl[1], NULL);
132  vp->z = (t == T_INT) ? (float) myint : myfloat;
133 }
134 
135 /*
136  * La procedure "fscanf_Position" lit en ascii un positionnement.
137  * Entree :
138  * pp Positionnement a lire.
139  */
140 void fscanf_Position (AritPosition *pp)
141 {
142  pusherr ("rotate: ");
143  fscanf_Vector (&pp->rotate);
144  popuperr ("scale: ");
145  fscanf_Vector (&pp->scale);
146  popuperr ("translate: ");
147  fscanf_Vector (&pp->translate);
148  poperr ();
149 }
150 
151 #endif