Subject: CGAL users discussion list
List archive
Re: [cgal-discuss] Fwd: How to do the nearest neighbor search on a Point_set_3 with properties
Chronological Thread
- From: Sebastien Loriot <>
- To:
- Subject: Re: [cgal-discuss] Fwd: How to do the nearest neighbor search on a Point_set_3 with properties
- Date: Fri, 4 Mar 2022 10:57:18 +0100
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
- Ironport-data: A9a23:+lHL4quo2AQMf1kJhLKN2OWsNefnVGFYMUV32f8akzHdYApBsoF/q tZmKWqCaPuPNzfyftkkboXg8E9XvpPQmoQ3TFZvqSoxRS0TgMeUXt7xwmXYb3rDdJWbJK5Ex 5xDMYeYdJhcolv0/ErF3m3J9CEkvU2wbuOgTraCY0idfCc8IMsboUsLd9UR38g52bBVPyvX4 Ymo+5aHZAf8s9JJGjt8B5yr+EsHUMva42twUmwWPZina3eD/5W9JMt3yZCZdxMUcKEMdgKJb 7qrIIWCw4/s10xF5uVJPVrMWhZirrb6ZWBig5fNMkSoqkAqSicais7XOBeAAKtao23hojx/9 DlCnbu9eFwOIqnXpKcMVAhYIhFiHZ1816CSdBBTseTLp6HHW37lwvErE0RveINEpqB4BmZB8 fFeIzcIBvyBr7jukfTrF6813JRlcJWD0IA34hmMyRnCCfE8QJffBaDOzdBd1TY0wMtJGJ4yY uJGN2I2PE2cC/FJElsPWKg8suLzv1fQSidJp0C1pqxpsneGmWSd15C0aIaPEjCQfu1ekU+c4 27H5G/kGQoyL82a0TPD83S2h+aJkzmTZW4JPLix9/ovn1jKg2JPVFsZUly0pfT/gUm7Mz5CF 6AK0g0jnPMV6EiwcprsWAy4kU6Yni4mdMUFRoXW9zqx4qbT5g+YAE0NQThAdMEquacKqdoCh g/hczTBVWwHjVGFdZ6O3uzL8m7qaED5OUdHNHBUF1JUizX2iNhr1kqnczp1LEKiYjTI9dzYx jmLqG0hguxWg5JXkaq8+l/DjnSnoZ2hou8JCuf/DjzNAuBRPtbNi2mUBb7zs6wowGGxEAPpg Z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jeHAgfiODqEjTzgSxGoN6lFkiiaOBVUvIz1fAxqDCDvS9fvaxvzN9ES73V+2bovmnbDLnIRK xB5ekJJ66KVtGZW3qk5FGtG4X5oa+KDnmfR7uXVLIoXreo+AilwkLE/gjxywL9U4SdYAf1tz XGK/5g+/hf/yLnJlmY0NXgG4ixGj4+Ko0h4bKDQ950bHG3B4ApI9mKITRIDu9piDNTr/aFW0 NnG0qzpe1Igu5rZ+9URA8/MJYeJKn0kZFDyHDnODQwZCzuvHW7ajk1Z1vqV8zfGy/py4oipg 5cIRrJBARYtEegGD01+ANEYCJJ+XzdhjrvCycBUuTyxqx7eQMgctZfCHKH3Y72nOHOSir9KY AENyLXzINEIN4H17Edlb0FzgIXAH0e4tT9lrShobwtyq0JIoiEWpogb1Efsawfr63gWR6bcd v8ejwJ/ZaEy8W6p7QtrYFXNoyQ0nQ86ntC32Vis
- Ironport-sdr: jfPlDCnHOX+sJjIHEtQu5fwlHPhwBRX4U0MmoroLiwVuDmMk8ELitkQqjEzFOy37qeYm8h2azt BP00itbPd1YhmafZICJjgKpFYQgDCzNcLTV2WbZiBWSYmTfA4Q42cClVAff1Bh5TWr/ggVGDGU myIEsG1gZlhrfpsFol78WqK/IynFG2x2BXXCRTLCymKeC7Z4hOkIECqO5XYf2D+suO0od0BFsb Vw1wjTQ124lDzXdKM6W0QqwE9KO/VnHv0OmIIQqtJQIxCBGDOsWT+0u7lbYsGbItGSifIvRgRs D9VGcQ+JRDoHDqjEoP2KMDfo
Could you please explain why you think there is a bug, with as assertion for example?
Thanks,
Sebastien.
On 3/3/22 04:06, Yaoyu Hu ( via cgal-discuss Mailing List) wrote:
I was so dumb that the compiling error in my previous email is due to a typo.
I have updated the sample code, now it compiles. Get the updated code here
https://gist.github.com/huyaoyu/6bd9e6b54bc895b7fadebe3863456e92 <https://gist.github.com/huyaoyu/6bd9e6b54bc895b7fadebe3863456e92>
Now I have a new problem. If I run the code, I got the following outputs. It seems that the search does not work for me. I must have done something wrong.
========== Outputs. ==========
Hello, test_point_set_nearest_neighbor!
index = 0, point: [ 0 0 0 ], color: [ 100, 100, 100 ]
index = 1, point: [ 0.1 0.1 0.1 ], color: [ 101, 101, 101 ]
index = 2, point: [ 0.2 0.2 0.2 ], color: [ 102, 102, 102 ]
index = 3, point: [ 0.3 0.3 0.3 ], color: [ 103, 103, 103 ]
index = 4, point: [ 0.4 0.4 0.4 ], color: [ 104, 104, 104 ]
index = 5, point: [ 0.5 0.5 0.5 ], color: [ 105, 105, 105 ]
index = 6, point: [ 0.6 0.6 0.6 ], color: [ 106, 106, 106 ]
index = 7, point: [ 0.7 0.7 0.7 ], color: [ 107, 107, 107 ]
index = 8, point: [ 0.8 0.8 0.8 ], color: [ 108, 108, 108 ]
index = 9, point: [ 0.9 0.9 0.9 ], color: [ 109, 109, 109 ]
Found nearest point of 0 0 0:
index = 6, distance = 0, point: [0.6 0.6 0.6 ]
color = [ 106, 106, 106 ]
========== Outputs end. ==========
Any help is appreciated.
Thank you!
Yaoyu
---------- Forwarded message ---------
From: *Yaoyu Hu* < <>>
Date: Wed, Mar 2, 2022 at 6:07 PM
Subject: How to do the nearest neighbor search on a Point_set_3 with properties
To: < <>>
Hi,
On CGAL v5.4, Ubuntu 20.04, g++ 9.3.0.
I'm trying to do the nearest neighbor search on a Point_set_3 object by "dD Spatial Searching". The Point_set_3 has a property for point color. I am trying to follow the example "Using a Point Property Map of a Polygonal Mesh " https://doc.cgal.org/latest/Spatial_searching/index.html#Spatial_searchingUsingSurfaceMesh <https://doc.cgal.org/latest/Spatial_searching/index.html#Spatial_searchingUsingSurfaceMesh>
The reason for referring to the above example is that I suppose points and colors are saved as property maps in Point_set_3 objects and I need to get the Index of a point from the Point_set_3 object, such that I can use the Index object to retrieve a color object saved in the property map. It looks like the relationship between mesh vertex descriptor and mesh point property.
I have two major questions based on my understanding of how Point_set_3 and "dD Spatial Searching " work:
(1) Do I need an explicit Point_set_3::Index value to be able to retrieve a property from a property_map of a Point_set_3 object? My current understanding is yes, I need to have a Point_set_3::Index value because the property_map is indexed by Point_set_3::Index objects.
(2) When doing a search by "dD Spatial Searching", if I want to have a Point_set_3::Index as the search result, I need to use things like CGAL::Search_traits_adapter such that the search tree will store Point_set_3::Index for me.
Based on the above thoughts, I have composed a sample code, which currently has some compile errors. I also created a GitHub gist if that is more convenient.
https://gist.github.com/huyaoyu/6bd9e6b54bc895b7fadebe3863456e92 <https://gist.github.com/huyaoyu/6bd9e6b54bc895b7fadebe3863456e92>
The compile error is shown after the code. The error says that CGAL::Search_traits_adapter needs three template arguments but I only give it one. I cannot understand why it gives this error since there are three template arguments already. I failed to proceed any further and I think it's better to ask for help from experts. I am also uncertain if my usage of "tree" and "search" is correct in the reset of the code.
Can someone help me to resolve the compile error and identify any other errors regarding "tree" and "search"? Thank you so much!
========== Code begins. ==========
#include <array>
#include <iostream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/Orthogonal_k_neighbor_search.h>
#include <CGAL/Search_traits_3.h>
#include <CGAL/Search_traits_adapter.h>
template < typename CloudT, typename ColorMapT >
typename boost::property_traits<ColorMapT>::value_type nearest_color(
const CloudT& cloud,
const ColorMapT& color_map,
const typename CloudT::Point_3& query) {
typedef typename boost::property_traits<ColorMapT>::value_type Color_t;
typedef typename CGAL::Kernel_traits<typename CloudT::Point_3>::Kernel CloudKernel_t;
typedef CGAL::Search_traits_3<CloudKernel_t> SearchTraits_base_t;
typedef CGAL::Search_traits_adapter<
typename CloutT::Index,
typename CloudT::Point_map,
SearchTraits_base_t
> SearchTraits_t;
typedef CGAL::Orthogonal_k_neighbor_search<SearchTraits_t> CloudSearch_t;
typedef CloudSearch_t::Tree CloudSearchTree_t;
typedef CloudSearchTree_t::Splitter CloudSearchSplitter_t;
typedef CloudSearch_t::Distance CloudSearchDistance_t;
// Set up a search tree.
CloudSearchTree_t tree(
cloud.begin(), cloud.end(),
CloudSearchSplitter_t(),
SearchTraits_t( cloud.point_map() ) );
// Search.
CloudSearchDistance_t distance( cloud.point_map() );
CloudSearch_t search( tree, query, 1, 0, true, distance );
const auto& neighbor_point_index = search.begin()->first;
auto& cloud_neighbor_color = color_map[neighbor_point_index];
return cloud_neighbor_color;
}
int main(int argc, char** argv) {
std::cout << "Hello, test_point_set_nearest_neighbor! \n";
typedef std::array< unsigned char, 3 > Color_t;
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel_t;
typedef Kernel_t::Point_3 Point_t;
typedef CGAL::Point_set_3<Point_t> PointSet_t;
PointSet_t cloud;
auto [ color_map, flag_added ] = cloud.add_property_map<Color_t>("color");
// Populate the point cloud with color.
// Omitted.
nearest_color( cloud, color_map, Point_t(0, 0, 0) );
return 0;
}
========== Code ends. ==========
========== Compile error begins. ==========
src/test_point_set_nearest_neighbor.cpp: In function ‘typename boost::property_traits<IndexMap>::value_type nearest_color(const CloudT&, const ColorMapT&, const typename CloudT::Point_3&)’:
/ws/src/shimizu_test_reconstruct_surface/src/test_point_set_nearest_neighbor.cpp:26:5: error: wrong number of template arguments (1, should be 3)
(Later error messages are omitted.)
========== Compile error ends. ==========
Thank you!
Yaoyu
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
- [cgal-discuss] How to do the nearest neighbor search on a Point_set_3 with properties, Yaoyu Hu, 03/03/2022
- [cgal-discuss] Fwd: How to do the nearest neighbor search on a Point_set_3 with properties, Yaoyu Hu, 03/03/2022
- Re: [cgal-discuss] Fwd: How to do the nearest neighbor search on a Point_set_3 with properties, Sebastien Loriot, 03/04/2022
- Re: [cgal-discuss] Fwd: How to do the nearest neighbor search on a Point_set_3 with properties, Yaoyu Hu, 03/06/2022
- Re: [cgal-discuss] Fwd: How to do the nearest neighbor search on a Point_set_3 with properties, Sebastien Loriot, 03/11/2022
- Re: [cgal-discuss] Fwd: How to do the nearest neighbor search on a Point_set_3 with properties, Yaoyu Hu, 03/06/2022
- Re: [cgal-discuss] Fwd: How to do the nearest neighbor search on a Point_set_3 with properties, Sebastien Loriot, 03/04/2022
- [cgal-discuss] Fwd: How to do the nearest neighbor search on a Point_set_3 with properties, Yaoyu Hu, 03/03/2022
Archive powered by MHonArc 2.6.19+.