From 458f2d21629bb6e1675252760a79f2f5ba7f7976 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 12 Apr 2013 16:33:43 +0000
Subject: [PATCH] fix coompile

---
 Common/Context.h                      |  2 -
 Common/GamePad.cpp                    | 91 +++++++++++----------------
 Common/GamePad.h                      | 23 +++----
 Mesh/meshGRegionDelaunayInsertion.cpp | 56 ++++++++---------
 4 files changed, 76 insertions(+), 96 deletions(-)

diff --git a/Common/Context.h b/Common/Context.h
index c521b4507b..093346e0b4 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -11,9 +11,7 @@
 #include <string>
 #include "CGNSOptions.h"
 #include "meshPartitionOptions.h"
-///
 #include "GamePad.h"
-///
 
 // The interface-independent context.
 
diff --git a/Common/GamePad.cpp b/Common/GamePad.cpp
index c615dc3a1c..27c3e392fc 100644
--- a/Common/GamePad.cpp
+++ b/Common/GamePad.cpp
@@ -5,7 +5,7 @@
 //
 // Contributed by Gilles Marckmann <gilles.marckmann@ec-nantes.fr>
 //    default map is "THRUSTMASTER FireStorm Dual Power"-like
-//                                         
+//
 //                    ######                                   ######
 //                   # but5 #                                 # but7 #
 //                 .########..                               ..#######.
@@ -48,29 +48,28 @@
 //     ....                                                                     ...
 //
 
+#include <math.h>
 #include <cstring>
 #include <string>
 #include <iostream>
 #include <stdio.h>
 #include "GamePad.h"
 #include "Context.h"
-#include <unistd.h>
-
 
-#if defined(WIN32)
-#include <math.h>
+#if !defined(WIN32)
+#include <unistd.h>
 #endif
-      
+
 GamePad::GamePad() : active(false), frequency(.01), gamepad_fd(0) {
 
 #if defined(WIN32)
- 
+
   for (int i = JOYSTICKID1 ; i < JOYSTICKID2 ; i++)  {
-    if(JOYERR_NOERROR == joyGetDevCaps(i, &caps, sizeof(JOYCAPS)) ) { 
+    if(JOYERR_NOERROR == joyGetDevCaps(i, &caps, sizeof(JOYCAPS)) ) {
       /*
       std::cout << "Joystick/Gamepad detected: "<< name ;
       std::cout << " ( "  << (int)caps.wNumAxes <<" axes /" ;
-      std::cout << (int)caps.wNumButtons <<" buttons)" << std::endl;    
+      std::cout << (int)caps.wNumButtons <<" buttons)" << std::endl;
       std::cout << "  Driver name ....... " << caps.szPname << std::endl;
       std::cout << "  Manufacturer ID ... " << caps.wMid << std::endl;
       std::cout << "  Product ID ........ " << caps.wPid << std::endl;
@@ -93,24 +92,23 @@ GamePad::GamePad() : active(false), frequency(.01), gamepad_fd(0) {
       */
       if(( 1./frequency <(double)caps.wPeriodMin ) ||( 1./frequency >(double)caps.wPeriodMax )){
 	   frequency=.1/(double)caps.wPeriodMin;
-	}     
+	}
       gamepad_fd =i;
       axes=std::min(GP_AXES,(int)caps.wNumAxes +2);
       buttons=std::min(GP_BUTTONS,(int)caps.wNumButtons);
       for (int i=0;i<buttons;i++) button[i]=false;
-      for (int i=0;i<axes;i++)    axe[i]=0.;    
-      active = true;    
-      
-      
+      for (int i=0;i<axes;i++)    axe[i]=0.;
+      active = true;
+
+
     }
-  }     
+  }
   for (int i=0;i<buttons;i++) button[i]=0;
   for (int i=0;i<axes;i++)	  axe[i]=0;
-  joyGetPosEx( gamepad_fd,&infoex)   ;      
+  joyGetPosEx( gamepad_fd,&infoex)   ;
   infoex.dwFlags = JOY_RETURNALL;
 
-#else
-#if defined(__APPLE__)
+#elif defined(__APPLE__)
 
   // ??
 
@@ -126,10 +124,9 @@ GamePad::GamePad() : active(false), frequency(.01), gamepad_fd(0) {
     std::cout << " (version " << version  << " / " ;
     std::cout << (int)axes <<" axes /" ;
     std::cout << (int)buttons <<" buttons)" << std::endl;
-    active = true;    
+    active = true;
   }
-#endif //(__APPLE__)
-#endif //(WIN32)
+#endif
 
   for (int i=0;i<std::min(9,(int)buttons);i++) button_map[i]=i;
   for (int i=0;i<std::min(7,(int)axes);i++)    axe_map[i]=i;
@@ -141,41 +138,34 @@ GamePad::GamePad() : active(false), frequency(.01), gamepad_fd(0) {
     button_map[1]=0;
     button_map[5]=6;
     button_map[6]=5;
-  } 
+  }
 }
 
-
 GamePad::~GamePad() {
-  active = false; 
+  active = false;
   gamepad_fd = 0;
 
-#if !defined(WIN32) 
-#if !defined(__APPLE__)
+#if !defined(WIN32) && !defined(__APPLE__)
 
   close(gamepad_fd);
 
-#endif //!(__APPLE__)
-#endif //!(WIN32)
+#endif
 }
 
-
-
 bool GamePad::toggle(const int _nbut) {
   bool res;
   if( toggle_status[_nbut] ){ res = true; toggle_status[_nbut]=false;}
   else { res=false;  }
   return res;
-} 
-
-
+}
 
 int GamePad::read_event() {
 
 #if defined(WIN32)
 
   infoex.dwFlags = JOY_RETURNALL;
-  joyGetPosEx( gamepad_fd,&infoex) ;   
-    
+  joyGetPosEx( gamepad_fd,&infoex) ;
+
     axe[0]=(double)(( 1.*infoex.dwXpos-32767.)/32767.);
     axe[1]=(double)(( 1.*infoex.dwYpos-32767.)/32767.);
     axe[2]=(double)(( 1.*infoex.dwRpos-32767.)/32767.);
@@ -184,25 +174,25 @@ int GamePad::read_event() {
       double alpha = 3.14159/18000.* infoex.dwPOV;
       axe[4]=1.001*sin(alpha);	 axe[5]=-1.001*cos(alpha);
     }
-    else{ 
+    else{
       axe[4]= axe[5]=0.;
     }
     for (int i=0;i<6;i++)  if ( fabs( axe[i]) < .01)  axe[i]=0.;
-   
+
     bool event=false;
     int  event_num;
     bool event_value;
     for (int i=0;i<buttons;i++){
-      int bin=pow(2,i);	 
+      int bin=pow(2,i);
       if( button[i] != (bool)(infoex.dwButtons & bin) ) {
 	event=true;
 	event_num=i;
 	event_value=(bool)(infoex.dwButtons & bin);
-      } 
-    }  
+      }
+    }
     if(event){
       if( button[event_num]==0 && event_value  ) {  toggle_status[event_num]=true; 	}
-      button[event_num]= event_value; 
+      button[event_num]= event_value;
     }
   /*
     std::cout<< "--------------------" << std::endl;
@@ -216,8 +206,7 @@ int GamePad::read_event() {
     std::cout<< infoex.dwButtonNumber << std::endl;
     std::cout<< infoex.dwPOV << std::endl;
   */
-#else
-#if defined(__APPLE__)
+#elif defined(__APPLE__)
 
   // ??
 
@@ -225,7 +214,7 @@ int GamePad::read_event() {
 
   int result = read(gamepad_fd, &event, sizeof(event)) ;
   if (result > 0)    {
-    
+
     switch (event.type)  {
     case JS_EVENT_INIT:
       break;
@@ -245,26 +234,23 @@ int GamePad::read_event() {
       button[(int)event.number]=(bool)event.value ;
       break;
 
-    default:	
+    default:
       break;
     }
   }
-  
-#endif //(__APPLE__)
-#endif //(WIN32)
+
+#endif
 
   return 1;
 }
 
-
-
 void GamePad::affiche() {
   for (int i=0;i<6;i++)  std::cout<<("_________");
   std::cout<<std::endl;  std::cout<<"  axis ";
   for (int i=0;i<6;i++)  std::cout<<" | "<<i;
   std::cout<<std::endl;  std::cout<<"       ";
   for (int i=0;i<6;i++)  std::cout<<" | "<< axe[i] ;
-  std::cout<<std::endl;   
+  std::cout<<std::endl;
   for (int i=0;i<10;i++) std::cout<< ("_____");
   std::cout<<std::endl;  std::cout<<" b.";
   for (int i=0;i<10;i++) std::cout<<" | "<<i;
@@ -273,6 +259,5 @@ void GamePad::affiche() {
   std::cout<<std::endl;
   for (int i=0;i<10;i++) std::cout<< ("_____");
   std::cout<<std::endl;
-  
-}
 
+}
diff --git a/Common/GamePad.h b/Common/GamePad.h
index 74ed1ae0dd..2d7b5ccb35 100644
--- a/Common/GamePad.h
+++ b/Common/GamePad.h
@@ -13,19 +13,16 @@
 #define GP_BUTTONS 32
 #define GP_AXES 6
 
-
 #if defined(WIN32)
-#include <windows.h>   
+#include <windows.h>
 #include <mmsystem.h>
-#else
-#if defined(__APPLE__)
+#elif defined(__APPLE__)
 // ??
 #else // LINUX
 #include <linux/joystick.h>
 #include <fcntl.h>
 #define GAMEPAD_DEV "/dev/input/js0"
 #endif
-#endif
 
 class GamePad {
  public:
@@ -37,9 +34,9 @@ class GamePad {
   ~GamePad();
   double axe[GP_AXES];
   bool button[GP_BUTTONS];
-  bool toggle(const int _nbut); 
-  int read_event(); 
-  void affiche(); 
+  bool toggle(const int _nbut);
+  int read_event();
+  void affiche();
   int button_map[10];
   int axe_map[8];
  private:
@@ -56,10 +53,11 @@ class GamePad {
   int axes;
   int buttons;
 
-#else
-#if defined(__APPLE__)
+#elif defined(__APPLE__)
 
   // ??
+  int axes;
+  int buttons;
 
 #else // LINUX
 
@@ -69,7 +67,6 @@ class GamePad {
   __u8 buttons;
 
 #endif
-#endif
-};  
+};
 
-#endif // _GAMEPAD_H_
+#endif
diff --git a/Mesh/meshGRegionDelaunayInsertion.cpp b/Mesh/meshGRegionDelaunayInsertion.cpp
index c446b1374f..6fff65a549 100644
--- a/Mesh/meshGRegionDelaunayInsertion.cpp
+++ b/Mesh/meshGRegionDelaunayInsertion.cpp
@@ -66,9 +66,9 @@ struct faceXtet{
     v[2] = t1->tet()->getVertex(faces[iFac][2]);
     std::sort(v, v + 3);
   }
- 
+
   inline MVertex * getVertex (int i) const { return t1->tet()->getVertex(faces[i1][i]);}
-  
+
  inline bool operator < (const faceXtet & other) const
   {
     if (v[0] < other.v[0]) return true;
@@ -106,7 +106,7 @@ void connectTets_vector(ITER beg, ITER end)
     if (!(*beg)->isDeleted()){
       for (int i = 0; i < 4; i++){
         faceXtet fxt(*beg, i);
-	std::vector<faceXtet>::iterator found  = std::find(conn.begin(), conn.end(), fxt); 
+	std::vector<faceXtet>::iterator found  = std::find(conn.begin(), conn.end(), fxt);
 	//        std::set<faceXtet>::iterator found = conn.find(fxt);
         if (found == conn.end())
 	  conn.push_back(fxt);
@@ -184,16 +184,16 @@ static void removeFromCavity (std::list<faceXtet> & shell,
 			      faceXtet &toRemove)
 {
   toRemove.t1->setDeleted(false);
-  cavity.erase(std::remove_if(cavity.begin(),cavity.end(), 
-			      std::bind2nd(std::equal_to<MTet4*>(), toRemove.t1))); 
+  cavity.erase(std::remove_if(cavity.begin(),cavity.end(),
+			      std::bind2nd(std::equal_to<MTet4*>(), toRemove.t1)));
   for (int i=0;i<4;i++){
-    faceXtet fxt2(toRemove.t1,i); 
-    std::list<faceXtet>::iterator it = std::find(shell.begin(),shell.end(),fxt2); 
+    faceXtet fxt2(toRemove.t1,i);
+    std::list<faceXtet>::iterator it = std::find(shell.begin(),shell.end(),fxt2);
     if (it == shell.end()){
       MTet4 *opposite = toRemove.t1->getNeigh(toRemove.i1);
       if (opposite){
 	for (int j=0;j<4;j++){
-	  faceXtet fxt3(opposite,j); 
+	  faceXtet fxt3(opposite,j);
 	  if (fxt3 == fxt2){
 	    shell.push_back(fxt3);
 	  }
@@ -211,9 +211,9 @@ static void extendCavity (std::list<faceXtet> & shell,
   MTet4 *t = toExtend.t1;
   MTet4 *opposite = t->getNeigh(toExtend.i1);
   for (int i=0;i<4;i++){
-    faceXtet fxt(opposite,i); 
-    std::list<faceXtet>::iterator it = std::find(shell.begin(),shell.end(),fxt); 
-    if (it == shell.end()) shell.push_back(fxt);    
+    faceXtet fxt(opposite,i);
+    std::list<faceXtet>::iterator it = std::find(shell.begin(),shell.end(),fxt);
+    if (it == shell.end()) shell.push_back(fxt);
     else shell.erase(it);
   }
   cavity.push_back(opposite);
@@ -244,7 +244,7 @@ int makeCavityStarShaped (std::list<faceXtet> & shell,
 			   MVertex *v ){
   std::list<faceXtet> wrong;
   for (std::list<faceXtet>::iterator it = shell.begin(); it != shell.end() ;++it) {
-    faceXtet &fxt = *it; 
+    faceXtet &fxt = *it;
     bool starShaped = fxt.visible(v);
     if (!starShaped){
       wrong.push_back(fxt);
@@ -253,10 +253,10 @@ int makeCavityStarShaped (std::list<faceXtet> & shell,
   if (wrong.empty()) return 0;
   //  printf ("cavity %p (shell size %d cavity size %d)is not star shaped (%d faces not visible), correcting it\n",
   //	  v,shell.size(),cavity.size(),wrong.size());
-  
+
   //  bool doneNothing = true;
   while (!wrong.empty()){
-    faceXtet &fxt = *(wrong.begin()); 
+    faceXtet &fxt = *(wrong.begin());
     std::list<faceXtet>::iterator its = std::find(shell.begin(),shell.end(),fxt);
     if (its != shell.end()){
       if (fxt.t1->getNeigh(fxt.i1) && fxt.t1->getNeigh(fxt.i1)->onWhat() == fxt.t1->onWhat() && verifyShell(v,fxt.t1->getNeigh(fxt.i1),shell)){
@@ -335,7 +335,7 @@ void nonrecurFindCavity(std::list<faceXtet> & shell,
     // the cavity that has to be removed
     // because it violates delaunay criterion
     cavity.push_back(t);
-    
+
     for (int i = 0; i < 4; i++){
       MTet4 *neigh = t->getNeigh(i) ;
       if (!neigh)
@@ -352,7 +352,7 @@ void nonrecurFindCavity(std::list<faceXtet> & shell,
   //  printf("cavity size %d\n",cavity.size());
 }
 
-void printTets (const char *fn, std::list<MTet4*> &cavity, bool force = false ) 
+void printTets (const char *fn, std::list<MTet4*> &cavity, bool force = false )
 {
   FILE *f = fopen (fn,"w");
   fprintf(f,"View \"\"{\n");
@@ -467,8 +467,8 @@ bool insertVertexB(std::list<faceXtet> &shell,
     //    printf("hola %d %g %g %22.15E\n",onePointIsTooClose, oldVolume, newVolume, 100.*fabs(oldVolume - newVolume) / oldVolume);
     //    new_cavity.clear();
     //    for (unsigned int i = 0; i <shell.size(); i++) new_cavity.push_back(newTets[i]);
-    //    printTets ("oldCavity.pos",cavity,true); 
-    //    printTets ("newCavity.pos",new_cavity); 
+    //    printTets ("oldCavity.pos",cavity,true);
+    //    printTets ("newCavity.pos",new_cavity);
     //    Msg::Fatal("");
     for (unsigned int i = 0; i <shell.size(); i++) myFactory.Free(newTets[i]);
     delete [] newTets;
@@ -496,7 +496,7 @@ bool insertVertex(MVertex *v,
   recurFindCavity(shell, cavity, v, t);
 
   return insertVertexB(shell,cavity,v,t,myFactory,allTets,vSizes,vSizesBGM,activeTets);
-  
+
 }
 
 
@@ -1177,7 +1177,7 @@ void insertVerticesInRegion (GRegion *gr)
   int COUNT_MISS_1 = 0;
   int COUNT_MISS_2 = 0;
 
-  clock_t t1 = clock();
+  double t1 = Cpu();
   while(1){
     if(allTets.empty()){
       Msg::Error("No tetrahedra in region %d %d", gr->tag(), allTets.size());
@@ -1221,23 +1221,23 @@ void insertVerticesInRegion (GRegion *gr)
       recurFindCavity(shell, cavity, &vv, worst);
 
       bool FOUND = false;
-      for (std::list<MTet4*>::iterator itc = cavity.begin(); itc != cavity.end(); ++itc){	  
+      for (std::list<MTet4*>::iterator itc = cavity.begin(); itc != cavity.end(); ++itc){
 	MTetrahedron *toto = (*itc)->tet();
 	//	(*itc)->setDeleted(false);
 	toto->xyz2uvw(center,uvw);
 	if (toto->isInside(uvw[0], uvw[1], uvw[2])){
 	  worst = (*itc);
 	  FOUND = true;
-	  break;	  
+	  break;
 	}
       }
       /// END TETS
-      
+
       if(FOUND){
         MVertex *v = new MVertex(center[0], center[1], center[2], worst->onWhat());
         v->setIndex(NUM++);
 
-	//	printTets ("before.pos", cavity, true); 
+	//	printTets ("before.pos", cavity, true);
 	bool starShaped = true;
 	bool correctCavity = false;
 	while (1){
@@ -1247,7 +1247,7 @@ void insertVerticesInRegion (GRegion *gr)
 	  else if (k == 1) correctCavity = true;
 	}
 	if (correctCavity && starShaped) NB_CORRECTION_OF_CAVITY ++;
-	//	    printTets ("after.pos", cavity, true); 
+	//	    printTets ("after.pos", cavity, true);
 	//}
 
         double lc1 =
@@ -1285,10 +1285,10 @@ void insertVerticesInRegion (GRegion *gr)
       memoryCleanup(myFactory, allTets);
     }
   }
-  
+
   memoryCleanup(myFactory, allTets);
-  clock_t t2 = clock();
-  double dt = (double)(t2-t1)/CLOCKS_PER_SEC;
+  double t2 = Cpu();
+  double dt = (t2-t1);
   int COUNT_MISS = COUNT_MISS_1+COUNT_MISS_2;
   Msg::Info("3D Point Insertion Terminated : %9d Delaunay cavities modified for star shapeness",NB_CORRECTION_OF_CAVITY);
   Msg::Info("                              : %9d points could not be inserted among %d",COUNT_MISS,vSizes.size() - COUNT_MISS);
-- 
GitLab