From e85eb4a7600086e2793ccd7cbd80bfc85ccd4051 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 3 Aug 2007 22:21:17 +0000
Subject: [PATCH] more fm work

---
 Fltk/GUI.cpp                               | 12 ++++--
 Fltk/GUI_Projection.cpp                    | 45 +++++++++++++++-------
 Fltk/GUI_Projection.h                      |  1 +
 contrib/FourierModel/ContinuationPatch.cpp | 23 -----------
 contrib/FourierModel/ContinuationPatch.h   |  1 -
 contrib/FourierModel/Makefile              |  9 ++---
 6 files changed, 44 insertions(+), 47 deletions(-)

diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index ed26aab50a..0c32589fb2 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.628 2007-08-03 00:44:28 geuzaine Exp $
+// $Id: GUI.cpp,v 1.629 2007-08-03 22:21:17 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -729,8 +729,13 @@ int GUI::global_shortcuts(int event)
     redraw_opengl();
     return 1;
   }
-  else if(Fl::test_shortcut(FL_ALT + 'd') ||
-	  Fl::test_shortcut(FL_ALT + FL_SHIFT + 'd')) {
+  else if(Fl::test_shortcut(FL_ALT + 'd')){
+    opt_geometry_surface_type(0, GMSH_SET | GMSH_GUI,
+			      !opt_geometry_surface_type(0, GMSH_GET, 0));
+    redraw_opengl();
+    return 1;
+  }
+  else if(Fl::test_shortcut(FL_ALT + FL_SHIFT + 'd')) {
     opt_mesh_surfaces_faces(0, GMSH_SET | GMSH_GUI,
 			    !opt_mesh_surfaces_faces(0, GMSH_GET, 0));
     redraw_opengl();
@@ -2305,6 +2310,7 @@ void GUI::create_option_window()
       geo_choice[2]->menu(menu_surface_display);
       geo_choice[2]->align(FL_ALIGN_RIGHT);	
       geo_choice[2]->callback(geometry_options_ok_cb);
+      geo_choice[2]->tooltip("(Alt+d)");
 
       o->end();
     }
diff --git a/Fltk/GUI_Projection.cpp b/Fltk/GUI_Projection.cpp
index d71544ac42..76475c189a 100644
--- a/Fltk/GUI_Projection.cpp
+++ b/Fltk/GUI_Projection.cpp
@@ -174,7 +174,7 @@ projectionEditor::projectionEditor(std::vector<FProjectionFace*> &faces)
   
   new Fl_Box(WB, WB + BH, BB / 2, BH, "Select:");
   
- Fl_Group *o = new Fl_Group(WB, WB, 2 * BB, 3 * BH);
+  Fl_Group *o = new Fl_Group(WB, WB, 2 * BB, 3 * BH);
   _select[0] = 
     new Fl_Round_Button(2 * WB + BB / 2, WB, BB, BH, "Points");
   _select[0]->value(1);
@@ -210,29 +210,29 @@ projectionEditor::projectionEditor(std::vector<FProjectionFace*> &faces)
   
   int hard = 8;
   hardEdges[0] = new Fl_Toggle_Button(WB, 3 * WB + 9 * BH + hard, 
-				      hard, height - 7 * WB - 12 * BH - 2 * hard);
+				      hard, height - 7 * WB - 13 * BH - 2 * hard);
   hardEdges[1] = new Fl_Toggle_Button(width - WB - hard, 3 * WB + 9 * BH + hard, 
-				      hard, height - 7 * WB - 12 * BH - 2 * hard);
+				      hard, height - 7 * WB - 13 * BH - 2 * hard);
   hardEdges[2] = new Fl_Toggle_Button(WB + hard, 3 * WB + 9 * BH, 
 				      width - 2 * WB - 2 * hard, hard);
-  hardEdges[3] = new Fl_Toggle_Button(WB + hard, -4 * WB - 3 * BH + height - hard,
+  hardEdges[3] = new Fl_Toggle_Button(WB + hard, height - 4 * WB - 4 * BH - hard,
 				      width - 2 * WB - 2 * hard, hard);
   for(int i = 0; i < 4; i++){
     hardEdges[i]->tooltip("Push to mark edge as `hard'");
   }  
 
   _uvPlot = new uvPlot(WB + hard, 3 * WB + 9 * BH + hard, 
-		       width - 2 * WB - 2 * hard, height - 7 * WB - 12 * BH - 2 * hard);
+		       width - 2 * WB - 2 * hard, height - 7 * WB - 13 * BH - 2 * hard);
   _uvPlot->end();
   
-  modes[0] = new Fl_Value_Input(WB, height - 3 * WB - 3 * BH, BB  / 2, BH);
+  modes[0] = new Fl_Value_Input(WB, height - 3 * WB - 4 * BH, BB  / 2, BH);
   modes[0]->tooltip("Number of Fourier modes along u");
-  modes[1] = new Fl_Value_Input(WB + BB / 2, height - 3 * WB - 3 * BH, BB  / 2, BH, 
+  modes[1] = new Fl_Value_Input(WB + BB / 2, height - 3 * WB - 4 * BH, BB  / 2, BH, 
 				"Fourier modes");
   modes[1]->tooltip("Number of Fourier modes along v");
-  modes[2] = new Fl_Value_Input(WB, height - 3 * WB - 2 * BH, BB  / 2, BH);
+  modes[2] = new Fl_Value_Input(WB, height - 3 * WB - 3 * BH, BB  / 2, BH);
   modes[2]->tooltip("Number of Chebyshev modes along u");
-  modes[3] = new Fl_Value_Input(WB + BB / 2, height - 3 * WB - 2 * BH, BB  / 2, BH, 
+  modes[3] = new Fl_Value_Input(WB + BB / 2, height - 3 * WB - 3 * BH, BB  / 2, BH, 
 				"Chebyshev modes");
   modes[3]->tooltip("Number of Chebyshev modes along v");
   for(int i = 0; i < 4; i++){
@@ -243,16 +243,26 @@ projectionEditor::projectionEditor(std::vector<FProjectionFace*> &faces)
     modes[i]->align(FL_ALIGN_RIGHT);
   }    
 
-  Fl_Button *b3 = new Fl_Button(width - WB - BB, height - 3 * WB - 3 * BH, 
-				BB, 2 * BH, "Generate\nPatch");
+  Fl_Button *b3 = new Fl_Button(width - WB - BB, height - 3 * WB - 4 * BH, 
+				BB, 2 * BH, "Generate\npatch");
   b3->callback(compute_cb, this);
 
-  
+  new Fl_Box(WB, height - 2 * WB - 2 * BH, BB / 2, BH, "Delete:");
+  Fl_Button *b4 = new Fl_Button(WB + BB / 2, height - 2 * WB - 2 * BH, BB / 2, BH, "last");
+  b4->callback(delete_cb, (void*)"last");
+  Fl_Button *b5 = new Fl_Button(WB + BB, height - 2 * WB - 2 * BH, BB / 2, BH, "select");
+  b5->callback(delete_cb, (void*)"select");
 
+  int s = width - 4 * WB - 3 * BB / 2;
+  Fl_Button *b6 = new Fl_Button(2 * WB + 3 * BB / 2, height - 2 * WB - 2 * BH, 
+				s / 2, BH, "Blend");
+  
+  Fl_Button *b7 = new Fl_Button(3 * WB + 3 * BB / 2 + s / 2, height - 2 * WB - 2 * BH, 
+				s / 2, BH, "Intersect");
 
-  Fl_Button *b4 = new Fl_Button(width - WB - BB, height - WB - BH,
+  Fl_Button *b8 = new Fl_Button(width - WB - BB, height - WB - BH,
 				BB, BH, "Cancel");
-  b4->callback(close_cb, _window);
+  b8->callback(close_cb, _window);
   
   _window->end();
   _window->hotspot(_window);
@@ -846,6 +856,13 @@ void compute_cb(Fl_Widget *w, void *data)
   Draw();
 }
 
+void delete_cb(Fl_Widget *w, void *data)
+{
+  char *str = (char*)data;
+  Msg(GERROR, "deleting %s", str);
+
+}
+
 void mesh_parameterize_cb(Fl_Widget* w, void* data)
 {
   // display geometry surfaces
diff --git a/Fltk/GUI_Projection.h b/Fltk/GUI_Projection.h
index 4e72b33389..01d559060e 100644
--- a/Fltk/GUI_Projection.h
+++ b/Fltk/GUI_Projection.h
@@ -32,6 +32,7 @@ void close_cb(Fl_Widget *w, void *data);
 void hide_cb(Fl_Widget *w, void *data);
 void save_cb(Fl_Widget *w, void *data);
 void compute_cb(Fl_Widget *w, void *data);
+void delete_cb(Fl_Widget *w, void *data);
 
 class uvPlot : public Fl_Window {
  private:
diff --git a/contrib/FourierModel/ContinuationPatch.cpp b/contrib/FourierModel/ContinuationPatch.cpp
index 1200e4df9e..4d76dafc67 100644
--- a/contrib/FourierModel/ContinuationPatch.cpp
+++ b/contrib/FourierModel/ContinuationPatch.cpp
@@ -463,8 +463,6 @@ void ContinuationPatch::_BackwardFft(int n, std::complex<double> *fftData)
 
 void ContinuationPatch::_ReprocessSeriesCoeff()
 {
-  bool direct = false;
-
   _coeffData = new std::complex<double>*[_uM];
   for(int j = 0; j < _uM; j++) {
     _coeffData[j] = new std::complex<double>[_vM];
@@ -490,7 +488,6 @@ void ContinuationPatch::_ReprocessSeriesCoeff()
       dataU[k] = new std::complex<double> [_uM];
     std::complex<double> *dataV = new std::complex<double>[2*_vM + 1];
     for (int j = 0; j < _uM - 1; j++) {
-      if (direct)
 	for (int k = 0; k < _vM + 1; k++) {
 	  //dataV[k] = 1.;
 	  //dataV[k] = 2. * cos(M_PI * v[k]) * cos(M_PI * v[k]) - 1.;
@@ -502,26 +499,6 @@ void ContinuationPatch::_ReprocessSeriesCoeff()
 	  //cos(2 * M_PI * u[j]);
 	  dataV[k] = _Interpolate(u[j],0.5 * cos(M_PI * v[k]) + 0.5);
 	}
-      else {
-	int nIntervals = 16;
-	double hIntervals = 0.5 / (double)nIntervals;
-	std::vector<double> tmpU(2 * nIntervals + 1);
-	std::vector<std::complex<double> > tmpData(2 * nIntervals + 1);
-	for (int l = 0; l < 2 * nIntervals + 1; l++)
-	  tmpU[l] = (double)l * hIntervals;
-	for (int l = 0; l < nIntervals + 1; l++) {
-	  tmpData[l] = tmpU[l];
-	  //tmpData[l] = _Interpolate(u[j],2 * tmpU[l]);
-	}
-	for (int l = 1; l < nIntervals + 1; l++)
-	  tmpData[nIntervals + l] = tmpData[nIntervals - l];
-	FftPolyInterpolator1D interpolator(tmpU,tmpData);
-	for (int k = 0; k < _vM + 1; k++) {
-	  dataV[k] = interpolator.F(0.5 * cos(0.5 * M_PI * v[k]) + 0.5);
-	  printf("%g : (%g,%g)\n",0.5 * cos(0.5 * M_PI * v[k]) + 0.5,
-		 dataV[k].real(),dataV[k].imag());
-	}
-      }
       for (int k = 1; k < _vM+1; k++)
 	dataV[_vM + k] = dataV[_vM -k];
       _BackwardFft(2*_vM + 1, dataV);
diff --git a/contrib/FourierModel/ContinuationPatch.h b/contrib/FourierModel/ContinuationPatch.h
index 9ab90c6097..ed8cdefdd5 100644
--- a/contrib/FourierModel/ContinuationPatch.h
+++ b/contrib/FourierModel/ContinuationPatch.h
@@ -5,7 +5,6 @@
 #include "Patch.h"
 #include "FM_Info.h"
 #include "PartitionOfUnity.h"
-#include "Interpolator1D.h"
 
 // The base class for the patches
 class ContinuationPatch : public Patch {
diff --git a/contrib/FourierModel/Makefile b/contrib/FourierModel/Makefile
index e2ce305570..c3f73e570b 100644
--- a/contrib/FourierModel/Makefile
+++ b/contrib/FourierModel/Makefile
@@ -23,8 +23,7 @@ SRC = ProjectionSurface.cpp \
       FM_Vertex.cpp\
       Message.cpp \
       Utils.cpp \
-      PartitionOfUnity.cpp \
-      Interpolator1D.cpp
+      PartitionOfUnity.cpp
 
 OBJ = ${SRC:.cpp=.o}
 
@@ -59,8 +58,7 @@ Patch.o: Patch.cpp Patch.h ProjectionSurface.h
 FPatch.o: FPatch.cpp Message.h FPatch.h Patch.h ProjectionSurface.h \
   PartitionOfUnity.h
 ContinuationPatch.o: ContinuationPatch.cpp Message.h ContinuationPatch.h \
-  Patch.h ProjectionSurface.h FM_Info.h PartitionOfUnity.h \
-  Interpolator1D.h
+  Patch.h ProjectionSurface.h FM_Info.h PartitionOfUnity.h
 ExactPatch.o: ExactPatch.cpp Message.h ExactPatch.h Patch.h \
   ProjectionSurface.h FM_Info.h
 Curve.o: Curve.cpp Curve.h
@@ -77,11 +75,10 @@ FM_Face.o: FM_Face.cpp FM_Face.h Patch.h ProjectionSurface.h FM_Edge.h \
 FM_Info.o: FM_Info.cpp FM_Info.h
 FM_Reader.o: FM_Reader.cpp Message.h FM_Reader.h Curve.h \
   IntersectionCurve.h Patch.h ProjectionSurface.h FM_Info.h ExactPatch.h \
-  ContinuationPatch.h PartitionOfUnity.h Interpolator1D.h \
+  ContinuationPatch.h PartitionOfUnity.h \
   CylindricalProjectionSurface.h RevolvedParabolaProjectionSurface.h \
   Utils.h FM_Face.h FM_Edge.h FM_Vertex.h BlendOperator.h BlendedPatch.h
 FM_Vertex.o: FM_Vertex.cpp
 Message.o: Message.cpp Message.h
 Utils.o: Utils.cpp Utils.h Message.h
 PartitionOfUnity.o: PartitionOfUnity.cpp PartitionOfUnity.h
-Interpolator1D.o: Interpolator1D.cpp Interpolator1D.h Message.h
-- 
GitLab