ViSP
 All Classes Functions Variables Enumerations Enumerator Friends Groups Pages
testColvector.cpp
1 /****************************************************************************
2  *
3  * $Id: testColvector.cpp 4056 2013-01-05 13:04:42Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 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  *
34  * Description:
35  * Test some vpColVector functionalities.
36  *
37  * Authors:
38  * Eric Marchand
39  *
40  *****************************************************************************/
41 
48 #include <visp/vpColVector.h>
49 #include <visp/vpDebug.h>
50 #include <visp/vpParseArgv.h>
51 
52 #include <stdlib.h>
53 #include <stdio.h>
54 
55 // List of allowed command line options
56 #define GETOPTARGS "h"
57 
58 
64 void usage(const char *name, const char *badparam)
65 {
66  fprintf(stdout, "\n\
67 Test some vpColVector functionalities.\n\
68 \n\
69 SYNOPSIS\n\
70  %s [-h]\n", name);
71 
72  fprintf(stdout, "\n\
73 OPTIONS: Default\n\
74  -h\n\
75  Print the help.\n");
76 
77  if (badparam)
78  fprintf(stdout, "\nERROR: Bad parameter [%s]\n", badparam);
79 }
87 bool getOptions(int argc, const char **argv)
88 {
89  const char *optarg;
90  int c;
91  while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) {
92 
93  switch (c) {
94  case 'h': usage(argv[0], NULL); return false; break;
95 
96  default:
97  usage(argv[0], optarg);
98  return false; break;
99  }
100  }
101 
102  if ((c == 1) || (c == -1)) {
103  // standalone param or error
104  usage(argv[0], NULL);
105  std::cerr << "ERROR: " << std::endl;
106  std::cerr << " Bad argument " << optarg << std::endl << std::endl;
107  return false;
108  }
109 
110  return true;
111 }
112 
113 
114 int
115 main(int argc, const char ** argv)
116 {
117  // Read the command line options
118  if (getOptions(argc, argv) == false) {
119  exit (-1);
120  }
121 
122  vpColVector V(4) ;
123  V = 1.0;
124 
125  vpTRACE("------------------------");
126  vpTRACE("call std::cout << V;");
127  std::cout << V << std::endl;
128 
129  vpTRACE("------------------------");
130  vpTRACE("call V.normalize();");
131  V.normalize();
132 
133  vpTRACE("------------------------");
134  vpTRACE("call std::cout << V;");
135  std::cout << V << std::endl;
136 
137 }
#define vpTRACE
Definition: vpDebug.h:401
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Definition: vpParseArgv.cpp:79
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72