Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
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 BEGIN_VISP_NAMESPACE
54 /*
55  * La procedure "fprintf_Position" ecrit en ascii un positionnement.
56  * Entree :
57  * f Fichier en sortie.
58  * pp Positionnement a ecrite.
59  */
60 void fprintf_Position(FILE *f, AritPosition *pp)
61 {
62  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,
63  pp->scale.x, pp->scale.y, pp->scale.z, pp->translate.x, pp->translate.y, pp->translate.z);
64 }
65 
66 /*
67  * La procedure "fscanf_Point3f" lit en ascii un point flottant 3D.
68  * Entree :
69  * pp Point flottant 3D a lire.
70  */
71 void fscanf_Point3f(Point3f *pp)
72 {
73  static const char *err_tbl[] = { "float expected (coordinate ", " of point)" };
74  int t;
75 
76  /* Lecture de la premiere coordonnee du point. */
77 
78  if ((t = lex()) != T_FLOAT && t != T_INT)
79  lexerr("start", err_tbl[0], "X", err_tbl[1], NULL);
80  pp->x = (t == T_INT) ? (float)myint : myfloat;
81 
82  /* Lecture de la seconde coordonnee du point. */
83 
84  if ((t = lex()) != T_FLOAT && t != T_INT)
85  lexerr("start", err_tbl[0], "Y", err_tbl[1], NULL);
86  pp->y = (t == T_INT) ? (float)myint : myfloat;
87 
88  /* Lecture de la troisieme coordonnee du point. */
89 
90  if ((t = lex()) != T_FLOAT && t != T_INT)
91  lexerr("start", err_tbl[0], "Z", err_tbl[1], NULL);
92  pp->z = (t == T_INT) ? (float)myint : myfloat;
93 }
94 
95 /*
96  * La procedure "fscanf_Vector" lit en ascii un vecteur.
97  * Entree :
98  * vp Vecteur a lire.
99  */
100 void fscanf_Vector(Vector *vp)
101 {
102  static const char *err_tbl[] = { "float expected (coordinate ", " of vector)" };
103 
104  int t;
105 
106  /* Lecture de la premiere coordonnee du vecteur. */
107 
108  if ((t = lex()) != T_FLOAT && t != T_INT)
109  lexerr("start", err_tbl[0], "X", err_tbl[1], NULL);
110  vp->x = (t == T_INT) ? (float)myint : myfloat;
111 
112  /* Lecture de la seconde coordonnee du vecteur. */
113 
114  if ((t = lex()) != T_FLOAT && t != T_INT)
115  lexerr("start", err_tbl[0], "Y", err_tbl[1], NULL);
116  vp->y = (t == T_INT) ? (float)myint : myfloat;
117 
118  /* Lecture de la troisieme coordonnee du vecteur. */
119 
120  if ((t = lex()) != T_FLOAT && t != T_INT)
121  lexerr("start", err_tbl[0], "Z", err_tbl[1], NULL);
122  vp->z = (t == T_INT) ? (float)myint : myfloat;
123 }
124 
125 /*
126  * La procedure "fscanf_Position" lit en ascii un positionnement.
127  * Entree :
128  * pp Positionnement a lire.
129  */
130 void fscanf_Position(AritPosition *pp)
131 {
132  pusherr("rotate: ");
133  fscanf_Vector(&pp->rotate);
134  popuperr("scale: ");
135  fscanf_Vector(&pp->scale);
136  popuperr("translate: ");
137  fscanf_Vector(&pp->translate);
138  poperr();
139 }
140 END_VISP_NAMESPACE
141 #endif