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