From 9e605b0feca86dbd2baf0b29e51ec1e7ef21908f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Oudin?= Date: Mon, 12 Feb 2018 11:37:38 +0100 Subject: [PATCH] Center is an attribute of ImplicitSurface. This way the search space for Marching Cubes is way smaller. --- Implicit.hpp | 4 ++++ spheroid.cpp | 2 +- spheroid.hpp | 1 - tests/TestImplicitSphere.hpp | 3 +-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Implicit.hpp b/Implicit.hpp index ce8264d..08d86e4 100644 --- a/Implicit.hpp +++ b/Implicit.hpp @@ -6,4 +6,8 @@ class ImplicitSurface { public: virtual double operator() (double x, double y, double z) const = 0; double operator()(const Point& pt) const; + Point getCenter() { return center;} + protected: + Point center; + ImplicitSurface(Point _center) : center(_center) {} }; diff --git a/spheroid.cpp b/spheroid.cpp index e66cfc5..d875aa3 100644 --- a/spheroid.cpp +++ b/spheroid.cpp @@ -5,7 +5,7 @@ #include "spheroid.hpp" Spheroid::Spheroid(Point& _center, size_t _p, size_t _q) : - center(_center), p(_p), q(_q), stiffness(0) { + ImplicitSurface(_center), p(_p), q(_q), stiffness(0) { _compute_volume(); } diff --git a/spheroid.hpp b/spheroid.hpp index 407e445..26357b7 100644 --- a/spheroid.hpp +++ b/spheroid.hpp @@ -31,7 +31,6 @@ class Spheroid : public ImplicitSurface { * V is the volume. Extremely useful to have a constant volume in the * ball **/ - Point& center; double p, q; size_t stiffness; double V; diff --git a/tests/TestImplicitSphere.hpp b/tests/TestImplicitSphere.hpp index 09b1fb9..ab0d13f 100644 --- a/tests/TestImplicitSphere.hpp +++ b/tests/TestImplicitSphere.hpp @@ -5,10 +5,9 @@ class TestImplicitSphere: public ImplicitSurface { public: TestImplicitSphere(const Point& center, double r): - center(center), radius(r) {} + ImplicitSurface(center), radius(r) {} virtual double operator()(double x, double y, double z) const; private: - Point center; double radius; };