Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Box_with_handle_d cannot take integer as handle?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Box_with_handle_d cannot take integer as handle?


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Box_with_handle_d cannot take integer as handle?
  • Date: Wed, 26 Oct 2011 08:07:36 +0200

Nothing surprizing:

in the doc here:
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Box_intersection_d_ref/Class_Box_intersection_d--Box_with_handle_d.html;

you can read that handle should be model of Handle concept, e.g., a pointer, an iterator, or a circulator.

No idea what you want to do with the int, but if it is to have one index
per triangle, you can do the following with Triangle_3::iterator it
&(*it)-&(triangles[0]) which will give you the position of the triangle
pointed by "it" in the vector triangles.

Otherwise, you can define you own model of BoxIntersectionBox_d concept
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Box_intersection_d_ref/Concept_BoxIntersectionBox_d.html#Cross_link_anchor_1719
by inheriting from CGAL::Box_intersection_d::Box_d<double,3>

Sebastien.


On 10/25/2011 06:41 AM, Graviton wrote:
I have this code-- it is modified from the
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Box_intersection_d/Chapter_main.html#Section_62.5
example here.


#include<CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include<CGAL/intersections.h>
#include<CGAL/point_generators_3.h>
#include<CGAL/Bbox_3.h>
#include<CGAL/box_intersection_d.h>
#include<CGAL/function_objects.h>
#include<CGAL/Join_input_iterator.h>
#include<CGAL/algorithm.h>
#include<vector>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point_3;
typedef Kernel::Triangle_3 Triangle_3;
typedef std::vector<Triangle_3> Triangles;
typedef Triangles::iterator Iterator;
typedef CGAL::Box_intersection_d::Box_with_handle_d<double,3,int> Box;

Triangles triangles; // global vector of all triangles

// callback function that reports all truly intersecting triangles
void report_inters( const Box& a, const Box& b) {
/* std::cout<< "Box "<< (a.handle() - triangles.begin())<< " and"
<< (b.handle() - triangles.begin())<< " intersect";
if ( ! a.handle()->is_degenerate()&& ! b.handle()->is_degenerate()
&& CGAL::do_intersect( *(a.handle()), *(b.handle()))) {
std::cout<< ", and the triangles intersect also";
}
std::cout<< '.'<< std::endl;*/
}

int main() {
// Create 10 random triangles
typedef CGAL::Random_points_in_cube_3<Point_3> Pts;
typedef CGAL::Creator_uniform_3< Point_3, Triangle_3> Creator;
typedef CGAL::Join_input_iterator_3<Pts,Pts,Pts,Creator> Triangle_gen;
Pts points( 1); // in centered cube [-1,1)^3
Triangle_gen triangle_gen( points, points, points);
CGAL::copy_n( triangle_gen, 10, std::back_inserter(triangles));

// Create the corresponding vector of bounding boxes
std::vector<Box> boxes;
for ( Iterator i = triangles.begin(); i != triangles.end(); ++i)
boxes.push_back( Box( i->bbox(), 0));

// Run the self intersection algorithm with all defaults
CGAL::box_self_intersection_d( boxes.begin(), boxes.end(),
report_inters);
return 0;
}



The only difference is this line

typedef CGAL::Box_intersection_d::Box_with_handle_d<double,3,int> Box;

The handle is now an int, instead of a Iterator.

And the compilation error I get is illegal indirection, which I think is
quite weird.

Any idea?

--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Box-with-handle-d-cannot-take-integer-as-handle-tp3935631p3935631.html
Sent from the cgal-discuss mailing list archive at Nabble.com.





Archive powered by MHonArc 2.6.18.

Top of Page