Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Spatial searching - Radius search with Surface_mesh

Subject: CGAL users discussion list

List archive

[cgal-discuss] Spatial searching - Radius search with Surface_mesh


Chronological Thread 
  • From: Eric Lombardi <>
  • To:
  • Subject: [cgal-discuss] Spatial searching - Radius search with Surface_mesh
  • Date: Wed, 12 Feb 2020 11:21:34 +0100
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:VznQ9B+M7aKYjf9uRHKM819IXTAuvvDOBiVQ1KB32+scTK2v8tzYMVDF4r011RmVBNmdta8P0rGempujcFJDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZrKeTpAI7SiNm82/yv95HJbAhEmTWwbalzIRi2ogndq8cbipZ+J6gszRfEvnRHd+NKyG1yOFmdhQz85sC+/J5i9yRfpfcs/NNeXKv5Yqo1U6VWACwpPG4p6sLrswLDTRaU6XsHTmoWiBtIDBPb4xz8Q5z8rzH1tut52CmdIM32UbU5Uims4qt3VBPljjoMOjgk+2/Vl8NwlrpWrhK8qRJhwIDabo+aO/Vica7GeNMWWXBMU9xNWyFPAI6xaZYEAeobPeZfqonwv1QArQG/BQawGejhzDhIhnrt0qIgyeQuDADG1xEnEt0QqnTUrcn6OL0WUeCyyanH1i/Mb+lL1jf884XIdhEhoeuNXbJra8be1U8vFxnejlmKp4zlJSqY2+IQuGaV6OpgUPigi28hqwxprTivx9ssionUho0O0FzL6SJ5wIMzKNalS0B7ecapHIZeuiyVLYd6XN4uTm5ytConybALuoS3cDUFxZkl3xLTdeCLf5SV7h/mVeucICt0iXdldb6jmxq+7E2txvDzW8Wq1VtKoCpIncTMu30IyRPe5MeKR/l480ql2TuP2R7f5+RALEA6j6XWJZgsyaMqmJUJq0TMBCr2lV32jKCIckUk/fCl5PjmYrX9vJ+cLIp0ih3mMqkhgMC/HOI4MgkQX2SC/eS91Lrj/UvkTLlQgP02iLHVsJHcJcsFuq60GxJZ34gs5hqlETuqzdsVkWMaIF9Gex+LlZXlNl7MLfzgCPewmVWskDNlx/DcOb3hB43AIWbZkLfgYblx8UpcyA02zd9E/Z1UEKwOIPPoV0/1tdzYFB45Mxeuz+n7DtV9zJgeVXiBAq+DKK/Sq0OH5vozI+mQY48YoCryK/c/6P7qlHM2hF4dfbK10psKc3C4Be9rI16ZYHrpmtcOC30Gvgs4TOzwiV2NSyRfZ3ioX/F02jZuA42vCcLPR5umnaea9Ca9BJxfIG5cWX6WFnK9Wp+FUL8obyeYK9Vtk3RQWKKgQMkl0hSkvRX2ypJjL/DV4WsTs4j4ktZvsb6A3Sou/CB5WpzOm1qGSHt5yztRG20GmZtnqEk48W+tlLBiiqUFR9hS/fJSFAw8L4WawfYoU4mjCDKERc+ATROdevvjBDgwStwrxNpXPhR5Gs+jlVbI2TCxRbEPxeXSWc4Et5nE1n20HP5TjnbL0K570gstQ9BVLmi6nvI56g7SGcvNgkKfzuCkb/ZE0Q==


Hello,

I'm looking for a way to do a radius search with Surface_mesh that returns a list of vertex descriptors.

The following example do what I want with Polyhedron_3:


"https://github.com/CGAL/cgal/blob/releases/CGAL-4.14.2/Spatial_searching/examples/Spatial_searching/searching_polyhedron_vertices_with_fuzzy_sphere.cpp";

I tried to change this example to make it work with Surface_mesh. The code compiles, but there is a runtime error:

terminate called after throwing an instance of
'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
Expr: parray_ != NULL
File: ~/CGAL-4.14.2/include/CGAL/Surface_mesh/Properties.h
Line: 576

The same error occurs with CGAL-4.14.2 and CGAL-5.0.1.


The source code is attached (radius_search.cpp). The "#if" at line 16 toggles between Polyhedron_3 and Surface_mesh.


What is wrong with Surface_mesh with this code ?


Regards,

--

Eric Lombardi

==============================================================
LIRIS, UMR 5205
Laboratoire d'InfoRmatique en Image et Systèmes d'information
Université Claude Bernard Lyon 1, bâtiment Nautibus
43 boulevard du 11 novembre 1918, 69622 Villeurbanne cedex

#include <CGAL/Cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Surface_mesh.h>

#include <CGAL/Search_traits_3.h>
#include <CGAL/Search_traits_adapter.h>
#include <CGAL/Kd_tree.h>
#include <CGAL/Fuzzy_sphere.h>

#include <fstream>


typedef CGAL::Cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
#if 0
typedef CGAL::Polyhedron_3<Kernel> Mesh;
#else
typedef CGAL::Surface_mesh<Point_3> Mesh;
#endif
typedef boost::graph_traits<Mesh>::vertex_descriptor     vertex_descriptor;
typedef boost::property_map<Mesh,
                            CGAL::vertex_point_t>::type  Vertex_point_pmap;

typedef CGAL::Search_traits_3<Kernel>                    Traits_base;
typedef CGAL::Search_traits_adapter<vertex_descriptor,
                                    Vertex_point_pmap,
                                    Traits_base>         Traits;

typedef CGAL::Kd_tree<Traits>                            Tree;
typedef Tree::Splitter                                   Splitter;


int main(int argc, char* argv[])
{
  Mesh mesh;
  std::ifstream in((argc>1)?argv[1]:"../tripod.off");
  in  >> mesh;
  Vertex_point_pmap vppmap = get(CGAL::vertex_point, mesh);

  // display number of vertices and 2 first points
  std::cout << "number of points = " << num_vertices(mesh) << std::endl;
  auto it = vertices(mesh).first;
  auto it_end = vertices(mesh).second;
  for(int i = 0; it != it_end && i < 2; i++, ++it)
  {
    Point_3 p = get(vppmap, *it);
    std::cout << "p = " << p << std::endl;
  }

  // Insert number_of_data_points in the tree
  Tree tree(vertices(mesh).begin(),
            vertices(mesh).end(),
            Splitter(),
            Traits(vppmap)
  );

  Point_3 query(0.0, 0.0, 0.0);
  double radius = 0.5;
  double epsilon = 0.01;

  // search vertices
  CGAL::Fuzzy_sphere<Traits> fz(query, radius, epsilon);
  
  //collect vertices that are inside the sphere
  std::list<vertex_descriptor> result;
  tree.search(std::back_inserter(result), fz);
  std::cout << "There are " << result.size() << " vertices inside the fuzzy sphere\n";

  return 0;
}

Attachment: tripod.off
Description: model/geomview-off

# Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications.

project( radius_search )


cmake_minimum_required(VERSION 2.8.11)

# CGAL and its components
find_package( CGAL QUIET COMPONENTS )

if ( NOT CGAL_FOUND )

message(STATUS "This project requires the CGAL library, and will not be
compiled.")
return()

endif()


# Boost and its components
find_package( Boost REQUIRED )

if ( NOT Boost_FOUND )

message(STATUS "This project requires the Boost library, and will not be
compiled.")

return()

endif()

# include for local directory

# include for local package

# ############################

add_executable( radius_search radius_search.cpp )
target_link_libraries(radius_search ${CGAL_LIBRARIES}
${CGAL_3RD_PARTY_LIBRARIES} )



Archive powered by MHonArc 2.6.18.

Top of Page