Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] make pair with std::vector<std::pair<Triangle,char*>>

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] make pair with std::vector<std::pair<Triangle,char*>>


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] make pair with std::vector<std::pair<Triangle,char*>>
  • Date: Mon, 30 Jan 2017 05:55:29 +0100
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:/CbD1xdBm7nvYTosYqExN4fOlGMj4u6mDksu8pMizoh2WeGdxc2zbR7h7PlgxGXEQZ/co6odzbGH7+a+AydYvt7B6ClEK8McEUddyI0/pE8JPo2sMQXDNvnkbig3ToxpdWRO2DWFC3VTA9v0fFbIo3e/vnY4ExT7MhdpdKyuQtaBx5f/6+fn8JLaZ0BEhSG2fKhpBBSwtwTY8McM0qV4LaNkgCDEqHJTZ+VbwytMIkiSmAq0pui9+5tu7z5Blfsq68laQOSwN/AjSbtCDTM6dWUxzMLuvBjHCwCI4y1PAS0tjhNUDl2dv1nBVZDrv36iuw==
  • Organization: GeometryFactory

The primitive time you are using is meant to be used with an iterator
which value type is the triangle type. If you want to use
something different, you need to use the lower level class
AABB_triangle [1] for example. You'll need to specify how to access
the triangle and a point from the iterator.
I've attached a compilable example.

Sebastien.

[1] http://doc.cgal.org/latest/AABB_tree/structCGAL_1_1AABB__primitive.html


On 01/27/2017 03:05 AM, DCOC wrote:
I am writing to see if it is possible to make_pair of Triangle_3 with
additional property, such that I use the following typedefs:

- typedef CGAL::Simple_cartesian<double> Kernel;
- typedef Kernel::FT FT;
- typedef Kernel::Point_3 Point;
- typedef Kernel::Triangle_3 Triangle;
- typedef std::vector<std::pair&lt;Triangle,char*>>::iterator Iterator;
- typedef CGAL::AABB_triangle_primitive<Kernel, Iterator>
AABB_triangle_Primitive;
- typedef CGAL::AABB_traits<Kernel, AABB_triangle_Primitive>
AABB_triangle_traits;
- typedef CGAL::AABB_tree<AABB_triangle_traits> AABB_triangle_Tree;

The triangle tree builds successfully in visual studio, but if I add the
next line of code:

- AABB_triangle_tree.accelerate_distance_queries();

or if I try to use the tree, such as a computation of a triangle distance to
a point, for example:

- AABB_triangle_tree.squared_distance(points[i]))

the code does not compile successfully, with the following error:

"Error 2 error C2664: 'const CGAL::Point_3<R_>
&CGAL::CommonKernelFunctors::Construct_vertex_3<K>::operator ()(const
CGAL::Tetrahedron_3<R_> &,int) const' : cannot convert parameter 1 from
'std::pair<_Ty1,_Ty2>' to 'const CGAL::Tetrahedron_3<R_> &'
C:\dev\CGAL-4.9\include\CGAL\AABB_triangle_primitive.h 47 1
ptDiffTest"

It is possible to make pair with point, for example, using:

- std::vector< std::pair<Point, unsigned> > points;

Is it not possible to do the same with Triangle. Thank you for your support.
Kind Regards, DC.



--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/make-pair-with-std-vector-std-pair-Triangle-char-tp4662487.html
Sent from the cgal-discuss mailing list archive at Nabble.com.


#include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_primitive.h>
#include <CGAL/property_map.h>

typedef CGAL::Simple_cartesian<double> Kernel; 
typedef Kernel::FT FT; 
typedef Kernel::Point_3 Point; 
typedef Kernel::Triangle_3 Triangle;
typedef std::pair<Triangle, char*> Pair_type;
typedef std::vector<Pair_type>::iterator Iterator; 

// Iterator -> Triangle
struct Triangle_map{
  typedef Iterator key_type;
  typedef Triangle value_type;
  typedef const Triangle& reference;
  typedef boost::readable_property_map_tag category;

  inline friend
  reference
  get(Triangle_map, Iterator it)
  {
    return it->first;
  }
};


// Iterator -> Point
struct Point_map{
  typedef Iterator key_type;
  typedef Point value_type;
  typedef const Point& reference;
  typedef boost::readable_property_map_tag category;

  inline friend
  reference
  get(Point_map, Iterator it)
  {
    return it->first[0];
  }
};

typedef CGAL::AABB_primitive<Iterator,
                             Triangle_map,
                             Point_map,
                             CGAL::Tag_false , CGAL::Tag_false > AABB_triangle_Primitive;
typedef CGAL::AABB_traits<Kernel, AABB_triangle_Primitive> AABB_triangle_traits; 
typedef CGAL::AABB_tree<AABB_triangle_traits> Tree; 
 
int main()
{
  std::vector<Pair_type> triangles;
  Tree tree(triangles.begin(), triangles.end());
  tree.accelerate_distance_queries();
  tree.closest_point_and_primitive(Point(0,0,0));
}



Archive powered by MHonArc 2.6.18.

Top of Page