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