Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] How to obtain the index of the point in dD spatial search

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] How to obtain the index of the point in dD spatial search


Chronological Thread 
  • From: "Jian Sun" <>
  • To:
  • Subject: Re: [cgal-discuss] How to obtain the index of the point in dD spatial search
  • Date: Sun, 11 May 2008 16:04:44 -0700
  • 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:references; b=LCcXIzRpFLJy+siYxASjxSkCHs3ZDgp5+z2TfwPsteUr/PIGgdVK4RbY8IDAq25gMXAIFnI8BRh4z1gTGnWcBv3t4u8//PRXYcetlEHCKuSncrL0SSviLVFbLQGqB/5zXEn+fFRj6ahhYWQYvAvTDegColK8cB5Eh6phUVow19Q=

Hi Kevin,

Thank you for your suggestion.  It is very helpful. But it does not works as it is.
One needs to define a comparison operator on Point.

It serves my purpose well now, though it is different from the solution that I am looking for.
I am looking for a way to customize Point_d as one does for the vertex in the Delaunay
triangulation. If that is doable, we can add an index into each point, which avoids the
extra step of looking up in map. 

sunjian

On Sun, May 11, 2008 at 2:12 AM, Kevin Xu <> wrote:
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!
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss




Archive powered by MHonArc 2.6.16.

Top of Page