Subject: CGAL users discussion list
List archive
- From: "Kevin Xu" <>
- To:
- Subject: Re: [cgal-discuss] How to obtain the index of the point in dD spatial search
- Date: Sun, 11 May 2008 17:12:19 +0800
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Q6xHin5tXiTIQInptFNSH6hURdpJNIWzKilLn6LizyrrVlDPba/pkLzQL2JhLxxEOlGhYEUXn2NSK/If6STgny4lvqhgqFYoN8a/pkPcAo8gBgKDIE0wgtNVIjDESI1zM7moMPyYRtumTfPmeDSQXZa7ebC+bHgS23km7QaBSgU=
Hi, Sun Jian,
You can use the map container provided by STL to achieve this.
Let's take the range search (with kd-tree) for example:
KD_tree STree; // define a kd tree for all vertices
std::map<Point,int> mVPToID; // map vertex pos. to index
std::map<Point,int>::iterator iPTI; // an iterator for mVPToID
// construct mapping
for (all vertices in a mesh or other data structure)
{
STree.insert (VP(i)); // add position of the ith vertex
mVPToID.insert (std::make_pair(VP(i), ID(i))); // make a map
between pos. & id
}
// perform range searching
std::vector<Point> FP; // store all found points (pos.)
Fuzzy_sphere fs(query_pos, dRadia, 0.0); // a fuzzy query sphere
STree.search(std::back_inserter(FP), fs); // do searching
// collect ids for the found points
for (int i=0; i<FP.size(); i++)
{
if ((iPTI=mVPToID.find(FP[i])) != mVPToID.end())
{ // find the record of FP[i] to get its id
ID(i) = iPTI->second; // id of the ith point is "iPTI->second"
}
}
/// end of the routine
The routines for k-NN search, etc., are similar.
HTH.
Good luck!
- How to obtain the index of the point in dD spatial search, Jian Sun, 05/11/2008
- Re: [cgal-discuss] How to obtain the index of the point in dD spatial search, Kevin Xu, 05/11/2008
- Re: [cgal-discuss] How to obtain the index of the point in dD spatial search, Jian Sun, 05/12/2008
- Re: [cgal-discuss] How to obtain the index of the point in dD spatial search, Kevin Xu, 05/12/2008
- Re: [cgal-discuss] How to obtain the index of the point in dD spatial search, Al Hasan, 05/15/2008
- Re: [cgal-discuss] How to obtain the index of the point in dD spatial search, Jian Sun, 05/12/2008
- Re: [cgal-discuss] How to obtain the index of the point in dD spatial search, Kevin Xu, 05/11/2008
Archive powered by MHonArc 2.6.16.