Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Passing a non-static member function pointer to Implicit_surface_3

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Passing a non-static member function pointer to Implicit_surface_3


Chronological Thread 
  • From: Nico Kruithof <>
  • To: "" <>
  • Subject: Re: [cgal-discuss] Passing a non-static member function pointer to Implicit_surface_3
  • Date: Thu, 4 Jul 2013 08:18:47 +0200

have a look at boost::bind. 


On Wed, Jul 3, 2013 at 5:05 PM, benj.bouvier <> wrote:
Hi all,
I'm having trouble passing to Implicit_surface_3 the pointer to a non-static
class member function. A simple demonstration based on the corresponding one
in the CGAL manual :

// ------------------------------------------------
typedef CGAL::Surface_mesh_default_triangulation_3 Tr;
typedef CGAL::Complex_2_in_triangulation_3
 C2t3;
typedef Tr::Geom_traits GT;
typedef GT::Sphere_3 Sphere_3;

// test class with implicit surface member function
class test {
public:
        GT::FT mySphere(GT::Point_3 p) {
                return p.x()*p.x() + p.y()*p.y() + p.z()*p.z() - 1;
        };
};

typedef GT::FT (test::*FunctionPointer)(GT::Point_3);
typedef CGAL::Implicit_surface_3<GT, FunctionPointer> Surface_3;

int main() {
  Tr tr;
  C2t3 c2t3 (tr);
  FunctionPointer fpoint = &test::mySphere;
  test tt;

  std::cout << (tt.*fpoint)(GT::Point_3(0, 0, 0)) << std::endl;    // this
compiles and prints OK
  Surface_3 surface((tt.*fpoint), Sphere_3(CGAL::ORIGIN, 10.)); // this does
not compile !
  CGAL::Surface_mesh_default_criteria_3
 criteria(30.,.1,.1);
  CGAL::make_surface_mesh(c2t3, surface, criteria,
CGAL::Non_manifold_tag());
}
// ------------------------------------------------------

I can call the member function fine using its pointer, but I cannot pass it
to Implicit_Surface_3 (I get "reference to non-static member function must
be called" errors). I'm no C++ specialist and would be glad to get any
pointers as to what I'm doing wrong. Thanks in advance !

Benjamin Bouvier



--
View this message in context: http://cgal-discuss.949826.n4.nabble.com/Passing-a-non-static-member-function-pointer-to-Implicit-surface-3-tp4657754.html
Sent from the cgal-discuss mailing list archive at Nabble.com.

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss





--
Nico Kruithof
nghk.nl



Archive powered by MHonArc 2.6.18.

Top of Page