Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] unique pointer to cgal::Polyhedron_3 objects created in loop

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] unique pointer to cgal::Polyhedron_3 objects created in loop


Chronological Thread 
  • From: Andreas Fabri <>
  • To:
  • Subject: Re: [cgal-discuss] unique pointer to cgal::Polyhedron_3 objects created in loop
  • Date: Wed, 27 May 2015 08:26:41 +0200
  • Organization: GeometryFactory

What you write would hold for any class.

for(...){

std::vector<int> V = FunctionThatCreatesAVector()

std::cout << &v << std::endl;
}

Your FunctionThatCreatesAVector()
should create a vector<int> with new
and then return the pointer.

andreas


On 27/05/2015 07:55, Daniel Abler wrote:
Dear List,

I would like to create a list of pointers to Polyhedron_3 objects (created in
a loop) for later meshing via Polyhedral_mesh_domain_3, as in the following
pseudocode:

struct K: public CGAL::Exact_predicates_inexact_constructions_kernel {};
typedef CGAL::Polyhedron_3<K> Polyhedron;
[...]

std::list<Polyhedron*> poly_pointer_list;

for (...)
{
[...]
Polyhedron cgalpoly =
FunctionThatCreatesCgalPolyhedronFromVTKPolyData;
poly_pointer_list.push_back(&cgalpoly);
}

The problem here is that &cgalpoly always points to the same address... I
suspect this has to do with the 'copy constructor' of Polyhedron_3 or my
'FunctionToCreateCgalPolyhedronFromVTKPolyData'.

How can I make sure that each cgalpoly created in the loop is kept in memory
and can be addressed by an unique pointer?

Many thanks,
Daniel




--
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912 skype: andreas.fabri



Archive powered by MHonArc 2.6.18.

Top of Page