Simplexus  1.0
Création d'un pavage par des simplexes de dimension N et visualisation graphique en dimension 2.
main_pavage.cpp
Go to the documentation of this file.
1 #include <cstddef>
2 #include <iostream>
3 #include <cstdlib>
4 #include <vector>
5 #include <string>
6 #include <utility>
7 #include <cassert>
8 #include "point.hpp"
9 #include "pavage.hpp"
10 #include "graphicutil.hpp"
11 #include "fileutil.hpp"
12 
13 
15 void testDrawPavage2(char* filepath);
16 void testPavageConsole(unsigned int dim, char* filepath);
17 
18 
19 int main(int argc, char* argv[]) {
20 
21  if (argc == 1){
22  std::cout << std::endl << "Taper ./bin/simplexus -h ou ./simplexus -help pour obtenir de l'aide" << std::endl << std::endl ;
23  return 0;
24  }
25  else if (strcmp(argv[1],"-help")==0 || strcmp(argv[1],"-h")==0 || (argc != 3 && argc != 4)){
26  std::cerr << std::endl << "Syntaxe : ./bin/simplexus <dimension du pavage> <fichier de points>"<< std::endl << std::endl ;
27  return 0;
28  }
29  else if (!isInteger(argv[1])){
30  std::cerr << std::endl << "Le premier argument est la dimension du pavage, ça doit être un entier" << std::endl << std::endl ;
31  return 0;
32  }
33  unsigned int dim = atoi(argv[1]);
34  if (dim <= 1){
35  std::cerr << std::endl << "La dimension ne peut pas être inférieure à deux" << std::endl << std::endl ;
36  return 0;
37  }
38  if (dim > 15){
39  std::cerr << std::endl << "La dimension ne peut pas être supérieure à 15" << std::endl << std::endl ;
40  return 0;
41  }
42 
43  char* filepath = argv[2];
44  if (dim == 2) {
45  if (argc == 4){
46  std::cout << "***************************************************************"<< std::endl;
47  std::cout << "***** Création pavage de dimension 2 avec affichage *****" << std::endl;
48  std::cout << "***************************************************************"<< std::endl;
49  testDrawPavage2(filepath);
50  }
51  else {
52  std::cout << "******************************************"<< std::endl;
53  std::cout << "***** Création pavage de dimension 2 *****" << std::endl;
54  std::cout << "******************************************"<< std::endl;
55  testPavageConsole(dim, filepath);
56  }
57  }
58  else {
59  std::cout << "*******************************************************"<< std::endl;
60  std::cout << "***** Création pavage de dimension " << dim << "*****" << dim << std::endl;
61  std::cout << "*******************************************************"<< std::endl;
62  testPavageConsole(dim, filepath);
63  }
64 
65  return 0;
66 }
67 
68 #define CASE_DIM(X) case X :{ Pavage<X> p(true); loadFromFile(p, file, filter); std::cout << p <<std::endl; break; }
69 
70 void testPavageConsole(unsigned int dim, char* filepath){
71 
72  const char* file = filepath;
73  bool filter = false;
74  //UGLY
75  switch(dim){
76  CASE_DIM(2)
77  CASE_DIM(3)
78  CASE_DIM(4)
79  CASE_DIM(5)
80  CASE_DIM(6)
81  CASE_DIM(7)
82  CASE_DIM(8)
83  CASE_DIM(9)
84  CASE_DIM(10)
85  CASE_DIM(11)
86  CASE_DIM(12)
87  CASE_DIM(13)
88  CASE_DIM(14)
89  CASE_DIM(15)
90  default :
91  break;
92  }
93 }
94 
95 void testDrawPavage2(char* filepath){
96  Pavage<2> p(false);
97  loadFromFile(p, filepath, true);
98  std::cout<<p<<std::endl;
99  drawPavage(p);
100 }
Bibliothèque d'opération sur des points de dimension N templatée.
#define CASE_DIM(X)
Definition: main_pavage.cpp:68
classe representant un pavage consitué de trisimplexe dans un espace de dimension N ...
Definition: pavage.hpp:38
void drawPavage(Pavage< 2 > &pavage)
Dessin d'un pavage.
Definition: graphicutil.cpp:6
int main(int argc, char *argv[])
Definition: main_pavage.cpp:19
void testPavageConsole(unsigned int dim, char *filepath)
Definition: main_pavage.cpp:70
Createur de pavage à partir d'une liste de points d'un fichier.
void testPavageDimension2()
void testDrawPavage2(char *filepath)
Definition: main_pavage.cpp:95
Construction d'un pavage, gestion d'ajout de point et interpolation d'un point du pavage...
bool isInteger(char *&s)
Determine si une chaine de caractere est un entier.
Definition: mathutil.hpp:48
void loadFromFile(Pavage< N > &pavage, const char *file, bool filter)
Initialise un pavage avec une séquence de points contenu dans un fichier.
Definition: fileutil.hpp:27