Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpAritio.cpp
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 https://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#include <visp3/core/vpConfig.h>
42
43#ifndef DOXYGEN_SHOULD_SKIP_THIS
44#include "vpArit.h"
45#include "vpLex.h"
46#include "vpMy.h"
47#include "vpToken.h"
48
49#include <stdio.h>
50
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 */
69void 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) ? static_cast<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) ? static_cast<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) ? static_cast<float>(myint) : myfloat;
91}
92
93/*
94 * La procedure "fscanf_Vector" lit en ascii un vecteur.
95 * Entree :
96 * vp Vecteur a lire.
97 */
98void 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) ? static_cast<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) ? static_cast<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) ? static_cast<float>(myint) : myfloat;
121}
122
123/*
124 * La procedure "fscanf_Position" lit en ascii un positionnement.
125 * Entree :
126 * pp Positionnement a lire.
127 */
128void 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}
138END_VISP_NAMESPACE
139#endif