From fdb69bc827992c930aed1ca89cc0175492231d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Tayeb?= Date: Wed, 16 Jun 2010 15:07:16 +0000 Subject: [PATCH] Mesh_3 demo: Replace Knot_3 function by Klein function. --- .../Mesh_3/implicit_functions/CMakeLists.txt | 2 +- ...nction.cpp => Klein_implicit_function.cpp} | 67 +++---------------- 2 files changed, 11 insertions(+), 58 deletions(-) rename Mesh_3/demo/Mesh_3/implicit_functions/{Knot_implicit_function.cpp => Klein_implicit_function.cpp} (51%) diff --git a/Mesh_3/demo/Mesh_3/implicit_functions/CMakeLists.txt b/Mesh_3/demo/Mesh_3/implicit_functions/CMakeLists.txt index 561f6829500..fb96e244bb5 100644 --- a/Mesh_3/demo/Mesh_3/implicit_functions/CMakeLists.txt +++ b/Mesh_3/demo/Mesh_3/implicit_functions/CMakeLists.txt @@ -60,7 +60,7 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND) polyhedron_demo_plugin(sphere_function_plugin Sphere_implicit_function) polyhedron_demo_plugin(tanglecube_function_plugin Tanglecube_implicit_function) - polyhedron_demo_plugin(knot_function_plugin Knot_implicit_function) + polyhedron_demo_plugin(klein_function_plugin Klein_implicit_function) else (CGAL_Qt4_FOUND AND QT4_FOUND) diff --git a/Mesh_3/demo/Mesh_3/implicit_functions/Knot_implicit_function.cpp b/Mesh_3/demo/Mesh_3/implicit_functions/Klein_implicit_function.cpp similarity index 51% rename from Mesh_3/demo/Mesh_3/implicit_functions/Knot_implicit_function.cpp rename to Mesh_3/demo/Mesh_3/implicit_functions/Klein_implicit_function.cpp index 1043de3c564..fb0c68132c1 100644 --- a/Mesh_3/demo/Mesh_3/implicit_functions/Knot_implicit_function.cpp +++ b/Mesh_3/demo/Mesh_3/implicit_functions/Klein_implicit_function.cpp @@ -24,10 +24,7 @@ #include #include "Implicit_function_interface.h" - -void puiss(double& x, double& y, int n); - -class Knot3_implicit_function : +class Klein_implicit_function : public QObject, public Implicit_function_interface { @@ -35,67 +32,23 @@ class Knot3_implicit_function : Q_INTERFACES(Implicit_function_interface); public: - virtual QString name() const { return "Knot3 function"; } + virtual QString name() const { return "Klein function"; } - virtual double operator()(double a, double b, double c) const + virtual double operator()(double x, double y, double z) const { - double e=0.025; - - double x, y, z, t, den; - den=1+a*a+b*b+c*c; - x=2*a/den; - y=2*b/den; - z=2*c/den; - t=(1-a*a-b*b-c*c)/den; - - double x19=x, y19=y, z17=z, t17=t; - puiss(x19,y19,19); - puiss(z17,t17,17); - - double f1 = z17-x19; - double f2 = t17-y19; - - f1 = f1*f1; - f2 = f2*f2; - e=e*e/(den-1); - - return f1+f2-e; + return (x*x+y*y+z*z+2*y-1) + * ( (x*x+y*y+z*z-2*y-1) *(x*x+y*y+z*z-2*y-1)-8*z*z) + + 16*x*z* (x*x+y*y+z*z-2*y-1); } virtual Bbox bbox() const { - const double radius = 4.; - double r = radius * 1.2; + const double radius = 6.; + double r = radius * 1.1; return Bbox(-r,-r,-r,r,r,r); } }; - - -void puiss(double& x, double& y, int n) { - - double xx = 1, yy = 0; - - while(n>0) { - if (n&1) { - double xxx = xx, yyy = yy; - xx = xxx*x - yyy*y; - yy = xxx*y + yyy*x; - } - - double xxx = x, yyy = y; - x=xxx*xxx-yyy*yyy; - y=2*xxx*yyy; - - n/=2; - } - - x = xx; - y = yy; -} - - - #include -Q_EXPORT_PLUGIN2(Knot3_implicit_function, Knot3_implicit_function); -#include "Knot_implicit_function.moc" +Q_EXPORT_PLUGIN2(Klein_implicit_function, Klein_implicit_function); +#include "Klein_implicit_function.moc"