Subject: CGAL users discussion list
List archive
- From: Kwok Jasper <>
- To: <>
- Subject: RE: [cgal-discuss] [HELP] about some advice related to the usage of
- Date: Sun, 8 Feb 2009 00:58:49 +0800
- Importance: Normal
Excuse me, for the code in the question that I have asked before, may I ask if I have understood the CGAL manual properly an used the structure and function there correctly. Although the my whole code can be compiled, it get exception the exception happen at different point of execution each time the program is run. But the point of execution is always inside the same for loop and each time the point where I get the exception involve a line of code that use the point() function I defined in the class Vertex_base_for_ssr I have already spent 2 days trying to solve the problem but I really dunno how that can be solved... Therefore, may I asked if the problem is due to that I have declare the derived class Vertex_base_for_ssr incorrectly ?? template < class GT, class Vb = CGAL::Triangulation_vertex_base_3<GT> > class Vertex_base_for_ssr : public Vb { public: typedef typename Vb::Vertex_handle Vertex_handle; typedef typename Vb::Cell_handle Cell_handle; typedef typename Vb::Point Point; template < class TDS2 > struct Rebind_TDS { typedef typename Vb::template Rebind_TDS<TDS2>::Other Vb2; typedef Vertex_base_for_ssr<GT, Vb2> Other; }; Vector surface_normal; vector<Vertex_handle> neighbor_vertex_handle; double fifth_nearest_dist; Vertex_base_for_ssr() {} Vertex_base_for_ssr(const Point& p) : Vb(p) {} Vertex_base_for_ssr(const Point& p, Cell_handle c) : Vb(p, c) {} void set_surface_normal(double x_i, double y_i, double z_i) { surface_normal = Vector(x_i, y_i, z_i); } Point get_point() { return Vb::point(); } }; >Thanks >Actually, the reason that I want to use vector<Vertex_handle> neighbor_vertex_handle >is that for each of the vertex, I want to record its k nearest neighbor (particularly, I want to record 55 nearest neighbor of a point) >In the CGAL manual , I found a function that return the nearest neighbor of a vertex but I cannot find the function that return k nearest neighbor. >Therefore, what I am trying now is to use the following for the k nearest neighbor search >typedef Rep_class::Point_3 Point; >typedef CGAL::Search_traits_3<Rep_class> Traits; >typedef CGAL::Orthogonal_k_neighbor_search<Traits> Neighbor_search; >typedef Neighbor_search::Tree Tree; > Tree tree_for_search; > vector<Point_3> neighbor; > vector<Point_3>::iterator n_itr; > > Finite_vertices_iterator initial = Dt.finite_vertices_begin(); > Fini te_vertices_iterator final = Dt.finite_vertices_end(); > Finite_vertices_iterator curr; > > Point_3 * temp; > > double tempX; > double tempY; > double tempZ; > > for(curr = initial; curr != final; ++curr) > { > tempX = (curr -> point()).x(); > tempY = (curr -> point()).y(); > tempZ = (curr -> point()).z(); > > temp = new Point_3(tempX, tempY, tempZ); > tree_for_search.insert(*temp); > delete temp; > temp = NULL; > } > > Neighbor_search * search; > Point_3 * query; > Neighbor_search::iterator itr; > > > for(curr = initial; curr != final; ++curr) > { > cout << ++i << "searching neighbor" << endl; > > tempX = (curr -> point()).x(); > tempY = (curr -> point()).y(); > tempZ = (curr -> point()).z(); > > query = new Point_3(tempX, tempY, tempZ); > search = new Neighbor_search(tree_for_search, *query, num_of_neighbor); > itr = search -> begin(); > ++itr; > int num=0; > for (; itr != search -> end(); ++itr) > { > ++num; > > if (num == 4) > { > curr -> fifth_nearest_dist = sqrt(itr -> second); > } > > neighbor.push_back(itr -> first); > } > > after that, I have a vector<Point_3> containing the coordiante of all the neighbors. > > Then, I get the vertex handle of the point in the triangulation having that those coordiante (I have implement a data structure to achieve this task ) > After that, I push those vertex_handle of the neighbor into the vector<Vertex_handle> of the vertex currently being processed. > > May I ask if the above approach has used CGAL improperly that I get the exception that I have mentioned in the previous email ? > >Thank you very much. >>Is there a specific reason why you want to store the neighbors in the From: To: Date: Wed, 4 Feb 2009 22:03:47 +0800 Subject: [cgal-discuss] [HELP] about some advice related to the usage of the derived class of CGAL::Triangulation_vertex_base_3<GT> Excuse me, I have the class below pedef CGAL::Vector_3<Rep_class> Vector; typedef CGAL::Point_3<Rep_class> Point_3; typedef CGAL::Object CGAL_object; template < class GT, class Vb = CGAL::Triangulation_vertex_base_3<GT> > class Vertex_base_for_ssr : public Vb { public: typedef typename Vb::Vertex_handle Vertex_handle; typedef typename Vb::Cell_handle Cell_handle; typedef typename Vb::Point Point; template < class TDS2 > struct Rebind_TDS { typedef typename Vb::template Rebind_TDS<TDS2>::Other Vb2; typedef Vertex_base_for_ssr<GT, Vb2> Other; }; vector<Vertex_handle> neighbor_vertex_handle; Vertex_base_for_ssr() {} Vertex_base_for_ssr(const Point& p) : Vb(p) {} Vertex_base_for_ssr(const Point& p, Cell_handle c) : Vb(p, c) {} Point point() { return Vb::point(); } }; typedef CGAL::Exact_predicates_inexact_constructions_kernel K; //typedef CGAL::Cartesian<double> K; typedef CGAL::Triangulation_data_structure_3<Vertex_base_for_ssr<K> > Tds; typedef CGAL::Delaunay_triangulation_3<K, Tds> Delaunay_triangulation; typedef Delaunay_triangulation::Vertex_handle Vertex_handle; typedef Delaunay_triangulation::Point Point; In the class Vertex_base_for_ssr, it has the member vector<Vertex_handle> neighbor_vertex_handle I have first insert points into a Triangulation, then for eac h vertex in the triangulation, I set its neighbor_vertex_handle to contain the vertex handle of the its neighbor points However, after that, when I use the following code, it have exception Finite_vertices_iterator initial = Dt.finite_vertices_begin(); Finite_vertices_iterator final = Dt.finite_vertices_end(); Finite_vertices_iterator curr; vector<Vertex_handle>::iterator nv_itr; for (curr = initial; curr != final; ++curr) { for(nv_itr = (curr -> neighbor_vertex_handle).begin(); nv_itr != (curr -> neighbor_vertex_handle).end(); ++nv_itr) { Vector v = Vector(((*nv_itr) -> point()).x(), ((*nv_itr) -> point()).x(), ((*nv_itr) -> point()).x()); } } May I ask if it is that I should not put the vector<Vertex_handle> neighbor_vertex_handle into the class Vertex_base_for_ssr?? Is it in the above code, I have declared and used the class Vertex_base_for_ssr in a wrong way ?? Or the problem should related to some other parts of the C++ code that I have written? May any one give me the direction about what I should do? Thank you very much Hotmail NOW! 沒有任何信箱比那會令您發熱發亮的來得吸引。 內在氣質才是致勝之道-您是哪一 最原始的溝通是用心的交流。 |
- [cgal-discuss] [HELP] about some advice related to the usage of the derived class of CGAL::Triangulation_vertex_base_3<GT>, Kwok Jasper, 02/04/2009
- Re: [cgal-discuss] [HELP] about some advice related to the usage, Monique Teillaud, 02/04/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage, Kwok Jasper, 02/05/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage of, Kwok Jasper, 02/07/2009
- Re: [cgal-discuss] [HELP] about some advice related to the usage of, Laurent Rineau (GeometryFactory), 02/07/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage of, Kwok Jasper, 02/08/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage of, Kwok Jasper, 02/08/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage of, Kwok Jasper, 02/09/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage of, Kwok Jasper, 02/10/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage of, Kwok Jasper, 02/10/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage of, Kwok Jasper, 02/10/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage of, Kwok Jasper, 02/10/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage of, Kwok Jasper, 02/09/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage of, Kwok Jasper, 02/08/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage of, Kwok Jasper, 02/08/2009
- Re: [cgal-discuss] [HELP] about some advice related to the usage of, Laurent Rineau (GeometryFactory), 02/07/2009
- Re: [cgal-discuss] [HELP] about some advice related to the usage of, Laurent Rineau (GeometryFactory), 02/10/2009
- RE: [cgal-discuss] [HELP] about some advice related to the usage of, Kwok Jasper, 02/11/2009
- Re: [cgal-discuss] [HELP] about some advice related to the usage, Monique Teillaud, 02/04/2009
Archive powered by MHonArc 2.6.16.