Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] How do I use a custom allocator, specifically on a Nef_polyhedron_3

Subject: CGAL users discussion list

List archive

[cgal-discuss] How do I use a custom allocator, specifically on a Nef_polyhedron_3


Chronological Thread 
  • From: marcosscriven <>
  • To:
  • Subject: [cgal-discuss] How do I use a custom allocator, specifically on a Nef_polyhedron_3
  • Date: Wed, 27 Mar 2013 11:38:04 -0700 (PDT)

So I've had some success storing std containers to a buffer, and passing the
whole buffer across, using Boost Interprocess. You can create an allocator
like this:

const int memsize = 65536;
static boost::aligned_storage<memsize>::type static_buffer;
managed_external_buffer objects_in_static_memory
(create_only, &static_buffer, memsize);

//This allocator will allocate memory inside the static buffer
typedef allocator<int, wmanaged_external_buffer::segment_manager>
allocator_t;

//Alias a STL compatible list to be constructed in the static buffer
typedef list<int, allocator_t> MyBufferList;

I can then transfer that whole buffer to another process, and Boost IPC will
allow me to reference the objects in it, without worrying about pointer
offsets.


Now, I notice that with the Polyhedron_3 one *can* use the 4th template to
specify an allocator.

But what about *Nef*_polyhedron_3?

I notice that when a NP3 is being generated from a stream, internally it
builds up an snc container, then calls an initialiser with a ref to that
container: NP3->pl()->inititilaise(&snc)

The internal SNC structure has an allocator for each of its types (vertices,
half edges etc).

Can anyone tell me, specifically, how I can use a customer allocator either
directly with the NP3, or at least with the internal snc structure. If I can
just pass a pointer to the SNC structure persisted on the buffer, to a new
NP3 instance, that could work.

Specifically, my NP3 type is:

typedef CGAL::Gmpq NT;
typedef CGAL::Cartesian<NT> CGAL_Kernel3;
typedef CGAL::Nef_polyhedron_3<CGAL_Kernel3> CGAL_Nef_polyhedron3;

Any help here greatly appreciated.

One final thing, I notice that there is a CGAL_ALLOCATOR macro that defaults
to a std allocator, but ideally, I'd like to only use the non-standard one
when I know I'm going to need to send it to another process.

Marcos



--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/How-do-I-use-a-custom-allocator-specifically-on-a-Nef-polyhedron-3-tp4657054.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.18.

Top of Page