Subject: CGAL users discussion list
List archive
- From: <>
- To:
- Subject: [cgal-discuss] How to change Kd-Tree Point extra info
- Date: Thu, 5 Jan 2012 07:37:47 +0100 (CET)
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point3;
struct Point:public Point3
{
Point(double dx,double dy,double dz):Point_3(dx,dy,dz)
{
bUsed = false;
}
AcDbObjectId id;
bool bUsed;
};
struct Construct_coord_iterator
{
// Get an iterator for the approximate coordinates.
const Point::Cartesian_const_iterator operator() (const Point&
nnp) const
{
return (nnp.cartesian_begin());
}
//Get a past-the-end iterator for the approximate
coordinates.
const Point::Cartesian_const_iterator operator() (const Point&
nnp, int) const
{
return (nnp.cartesian_end());
}
};
typedef CGAL::Search_traits<K::FT, Point, const
double*,Construct_coord_iterator> Traits;
typedef CGAL::Orthogonal_incremental_neighbor_search<Traits>
NN_incremental_search;
typedef NN_incremental_search::iterator NN_iterator;
typedef NN_incremental_search::Tree Tree;
struct point_not_used{
bool operator()(const NN_iterator& it)
{
return (((*it).first).bUsed);
//return true;
}
};
// An iterator that only enumerates dD points with positive
x-coordinate
typedef CGAL::Filter_iterator<NN_iterator,point_not_used>
NN_positive_x_iterator;
.... //init a Tree ojbect and do the below seach.
NN_incremental_search NN(tree,query);
NN_positive_x_iterator
it(NN.end(),point_not_used(),NN.begin()),end(NN.end(),point_not_used());
for (int j=0;(j<nK)&&(it!=end);++j,++it)
{
const Point& p = (*it).first;
Point& pp = const_cast<Point&>(p);
pp.bUsed = true;// why can this line not change the
tree's point extra info "bUsed".
idArr_Res.append(p.id);
acutPrintf(_T("\nsquard
distance=%g"),CGAL::to_double((*it).second));
}
the code above can be compiled well, but "pp.bUsed = true" did nothing, why
can't change the tree's point extral info.
- [cgal-discuss] How to change Kd-Tree Point extra info, 421232206, 01/05/2012
- Re: [cgal-discuss] How to change Kd-Tree Point extra info, Sebastien Loriot (GeometryFactory), 01/05/2012
- [cgal-discuss] Re: How to change Kd-Tree Point extra info, cnng0315, 01/05/2012
- Re: [cgal-discuss] Re: How to change Kd-Tree Point extra info, Sebastien Loriot (GeometryFactory), 01/05/2012
- [cgal-discuss] Re: How to change Kd-Tree Point extra info, cnng0315, 01/06/2012
- Re: [cgal-discuss] Re: How to change Kd-Tree Point extra info, Sebastien Loriot (GeometryFactory), 01/05/2012
- [cgal-discuss] Re: How to change Kd-Tree Point extra info, cnng0315, 01/05/2012
- Re: [cgal-discuss] How to change Kd-Tree Point extra info, Sebastien Loriot (GeometryFactory), 01/05/2012
Archive powered by MHonArc 2.6.16.