Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] 3D Mesh Generation Sphere example - changing radius?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] 3D Mesh Generation Sphere example - changing radius?


Chronological Thread 
  • From: "Laurent Rineau (CGAL/GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] 3D Mesh Generation Sphere example - changing radius?
  • Date: Tue, 29 Oct 2013 11:23:51 +0100
  • Organization: GeometryFactory

Le lundi 28 octobre 2013 13:57:10 msmith81 a écrit :

> thanks! It appears that functors are just what I was looking for... but I am

> too much of a newb to get them to work I've never used functors before -

> can someone with more c++ experience tell me what I am missing? I found

> this source

> <http://www.stanford.edu/class/cs106l/course-reader/Ch13_Functors.pdf> and

> wrote a functor as:

>

> class SphereFunction {

> public:

> explicit SphereFunction(const FT sr) : squaredRadius(sr) {}

> FT operator() (const Point& p)

> { return CGAL::squared_distance(p, Point(CGAL::ORIGIN))-squaredRadius; }

> private:

> const FT squaredRadius;

> };

 

Your operator() should be const:

 

FT operator() (const Point& p) const

 

> I then tried calling this in the code as:

>

> FT radius = 10.0;

> SphereFunction sphere_function(radius*radius);

> Mesh_domain domain(sphere_function, K::Sphere_3(CGAL::ORIGIN,

> (radius*radius*2.0)));

>

> but it doesn't compile because "cannot convert parameter 1 from

> 'SphereFunction' to 'Function (__cdecl &)' "

> I suspect that the problem has a lot to do with these two typedef lines:

>

> typedef FT (Function)(const Point&);

> typedef CGAL::Implicit_mesh_domain_3<Function,K> Mesh_domain;

>

> but with my limited c++ knowledge, I just have no idea what to modify or how

> to modify it. Can someone please help?

 

'Function' is the type of the function 'sphere_function'.

 

Replace those two lines with:

 

typedef CGAL::Implicit_mesh_domain_3<SphereFunction,K> Mesh_domain;

 

and be sure that the declaration of SphereFunction appears before that line. Or add a forward declaration of your class:

 

class SphereFunction;

typedef CGAL::Implicit_mesh_domain_3<SphereFunction,K> Mesh_domain;

 

--

Laurent Rineau, PhD

R&D Engineer at GeometryFactory http://www.geometryfactory.com/

Release Manager of the CGAL Project http://www.cgal.org/

 




Archive powered by MHonArc 2.6.18.

Top of Page