Subject: CGAL users discussion list
List archive
- From:
- To:
- Subject: Re: Re : [cgal-discuss] A problem with iso oriented box intersection
- Date: Thu, 11 Dec 2008 13:32:36 +0100 (CET)
package
MIME-Version: 1.0
Date: Thu, 11 Dec 2008 13:34:51 +0100
From:
<>
X-Webmail-UserID:
X-Originating-IP: 93.1.126.250
In-Reply-To:
<>
References:
<>
<>
<>
<>
<>
Message-ID:
<6d8e66f7ad2705e552af63564956f438@localhost>
X-Sender:
User-Agent: RoundCube Webmail/0.1
Content-Type: multipart/alternative;
boundary="=_abaa58435ed1bfb9f1c74434826d3a3a"
X-Ovh-Tracer-Id: 609674800858562839
--=_abaa58435ed1bfb9f1c74434826d3a3a
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="UTF-8"
Hello,
My answer to just rename callback to operator() was too simplistic.
The object is passed as a copy and not as a reference. That means
that the list is copied.
So you need a light-weight object with a pointer to the heavy weight
object of type My_class.
This is not particular for CGAL but normal for function objects, e.g.
functors in STL algorithms.
andreas
On Thu, 11 Dec 2008 11:27:26 +0000 (GMT), BBB HHH wrote: Hello,
I used the operator() which resolved the problem. But i have another
problem. The operator() is given below:
void operator()(const& Box a, const Box
// Here i want to compute the index of the box a in the list of boxes by
finding the distance between the box1.handle() (which is of type //
std::list::iterator) and the trinagles.begin() (which is also of the same
type). The index allows me to find corresponding //triangles in my list of
triangles and do futher processing.
}
My program compiles successfully but it crashes when trying to
execute the
line inside the operator().
I am using Visual Studio 2005 with SP. The error is "list iterators
incompatible".
My program is included below.
Thanks in advance
Hichem Barki
#include
#include
#include
#include
#include
#include
#include
using std::cout;
using std::cin;
using std::endl;
template
class My_class
{
public:
typedef typename Kernel::FT Number_type;
typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Point_3 Point_3;
typedef typename std::list< Triangle_3> Triangles;
typedef typename Triangles::iterator tri_it;
typedef CGAL::Box_intersection_d::Box_with_handle_d Box;
// Member data
Triangles triangles; // List of the superset triangles
// Constructors
My_class(...)
{
// Fill the list of Triangles
.....
}
void operator()(const& Box a, const Box
}
void get_inters_bboxes()
{
// Create the corresponding vector of bounding boxes
std::vector boxes;
for (tri_it iter = triangles.begin(); iter !=
triangles.end(); ++iter)
boxes.push_back( Box( iter->bbox(), iter));
// Run the self intersection algorithm with all defaults
CGAL::box_self_intersection_d(boxes.begin(), boxes.end(), callback, 10,
CGAL::Box_intersection_d::HALF_OPEN);
}
};
-------------------------
DE : Pierre Alliez
:
ENVOY LE : Mercredi, 10 Dcembre 2008, 12h14mn 29s
OBJET : Re: [cgal-discuss] A problem with iso oriented box intersection
package
hi Hichem,
that is tricky indeed - have already encountered this issue which was
solved with the help of Andreas Fabri.
I send you my self_intersect global function, which takes as parameters a
CGAL polyhedron, and an output iterator where I write all triangles which
interesect. as you can see I can pass to the intersection engine a class
Intersect_facets with a parameterized constructor.
the callback function is the operator () of that class.
good luck!
pierre
BBB HHH a crit : Hello,
I am working with the
CGAL::box_self_intersection_d to detect
interrsections in a list of bboxes of triangles. I want to do this in an
object oriented manner (inside a class). Some parts of my code are listed
below. I can not compile my program since there are several errors in the
line using box_self_intersection_d.
I think the error is the use of the callback of box_self_intersection_d.
In my program this callback is a class member function. In the examples
provided by CGAL. The callback is a global function and the
box_self_intersection_d function is called inside main(). Can someone help
me to detect the problem (how to put a function object inside a class
template and how to use it correctly). I tried a global function as a
callback, the compile succeds but i can not acces the member data of my
class.
Thanks in advance
Hichem BARKI
#include
#include
#include
#include
#include
#include
#include
using std::cout;
using std::cin;
using std::endl;
template
class My_class
{
public:
typedef typename Kernel::FT Number_type;
typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Point_3 Point_3;
typedef typename std::list< Triangle_3> Triangles;
typedef typename Triangles::iterator tri_it;
typedef CGAL::Box_intersection_d::Box_with_handle_d Box;
// Member data
Triangles triangles; // List of the superset triangles
// Constructors
My_class(...)
{
// Fill the list of Triangles
.....
}
void callback(const& Box a, const Box font-size: x-small;"> void
get_inters_bboxes()
{
// Create the corresponding vector of bounding boxes
std::vector boxes;
for (tri_it iter = triangles.begin(); iter != triangles.end(); ++iter)
boxes.push_back( Box( iter->bbox(), iter));
// Run the self intersection algorithm with all defaults
CGAL::box_self_intersection_d(boxes.begin(), boxes.end(), callback, 10,
CGAL::Box_intersection_d::HALF_OPEN);
}
};
--
Pierre Alliez
INRIA Sophia Antipolis - Mediterranee
Project-team GEOMETRICA
http://www-sop.inria.fr/members/Pierre.Alliez/
Tel: +33 4 92 38 76 77
Fax: +33 4 97 15 53 95
--=_abaa58435ed1bfb9f1c74434826d3a3a
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset="UTF-8"
<p>Hello,</p>
<p>My answer to just rename callback to operator() was too simplistic.</p>
<p>The object is passed as a copy and not as a reference. That means</p>
<p>that the list is copied.</p>
<p>So you need a light-weight object with a pointer to the heavy weight</p>
<p>object of type My_class.</p>
<p>This is not particular for CGAL but normal for function obje=
cts, e.g.</p>
<p>functors in STL algorithms.</p>
<p> </p>
<p>andreas</p>
<p> </p>
<p>On Thu, 11 Dec 2008 11:27:26 +0000 (GMT), BBB HHH
<h_hachimodo@yahoo=
=2Efr> wrote:</p>
<blockquote style=3D"border-left: 2px solid #1010ff; padding-left: 5px; mar=
gin-left: 5px; width: 100%;"><!-- DIV {margin:0px;} -->
<div style=3D"font-family:times new roman,new york,times,serif;font-size:14=
pt">
<div>Hello,<br /><br />I used the operator() which resolved the problem. Bu=
t i have another problem. The operator() is given below:<br /><br /><span s=
tyle=3D"font-family: Default Sans Serif,Verdana,Arial,Helvetica,sans-serif;=
font-size: x-small;">void </span><span style=3D"font-family: Default Sans =
Serif,Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">operator()</=
span>(const& Box a, const Box& b)<br /> {<br /> Triangles::differen=
ce_type index =3D std::distance(triangles.begin(), box1.handle());<br /> //=
Here i want to compute the index of the box a in the list of boxes by find=
ing the distance between the box1.handle() (which is of type // std=
::list::iterator) and the trinagles.begin() (which is also of the same type=
). The index allows me to find corresponding //triangles in my list of tr=
iangles and do futher processing.<br /> }<br /><br />My program compiles su=
ccessfully but it crashes when trying to execute the line inside the operat=
or().<br />I am using Visual Studio 2005 with SP. The error is "list iterat=
ors incompatible".<br /><br />My program is included below.<br />Thanks in =
advance<br />Hichem Barki<br /><br /><span style=3D"font-family: Default Sa=
ns Serif,Verdana,Arial,Helvetica,sans-serif; font-size: x-small;">#include =
<br /> #include <br /> #include <br /> #include <br /> #include <br /> #inc=
lude <br /> #include <br /> <br /> <br /> using std::cout;<br /> using std:=
:cin;<br /> using std::endl;<br /> <br /> template <br /> class My_class<br=
/> {<br /> public:<br /> typedef typename Kernel::FT =
Number_type;<br /> typedef typename Kernel::Point_2 =
Point_2;<br /> typedef typename Kernel::P=
oint_3 Point_3;<br /> typedef typename s=
td::list< Triangle_3> Triangles;<br />=
typedef typename Triangles::iterator =
tri_it;<br /> <br /> typedef CGAL::Box_intersection_d::Box_with_handl=
e_d Box;<br /> <br /> // Member data<br /> Triangles =
triangles; // List of the superset =
triangles<br /> <br /> // Constructors<br /> My_class(...)<br /> {<br /> //=
Fill the list of Triangles<br /> .....<br /> <br /> }<br /> void </span><s=
pan style=3D"font-family: Default Sans Serif,Verdana,Arial,Helvetica,sans-s=
erif; font-size: x-small;">operator()</span>(const& Box a, const Box&am=
p; b)<br /> {<br /> Triangles::difference_type index =3D std::distance(tria=
ngles.begin(), box1.handle());<br /> }<br /> <span style=3D"font-family: De=
fault Sans Serif,Verdana,Arial,Helvetica,sans-serif; font-size: x-small;"> =
void get_inters_bboxes()<br /> {<br /> // Create the corresponding vector o=
f bounding boxes<br /> std::vector boxes;<br /> for (tri_it iter =3D triang=
les.begin(); iter !=3D triangles.end(); ++iter)<br /> boxes.push_back( Box(=
iter->bbox(), iter));<br /> <br /> // Run the self intersection algorit=
hm with all defaults<br /> CGAL::box_self_intersection_d(boxes.begin(), box=
es.end(), callback, 10, CGAL::Box_intersection_d::HALF_OPEN);<br /> }<br />=
<br /> <br /> };<br /> </span><br /></div>
<div style=3D"font-family: times new roman,new york,times,serif; font-size:=
14pt;"><br />
<div style=3D"font-family: times new roman,new york,times,serif; font-size:=
12pt;"><span style=3D"font-family: Tahoma; font-size: x-small;">
<hr size=3D"1" />
<strong><span style=3D"font-weight: bold;">De :</span></strong> Pierre Alli=
ez <br /><strong><span style=3D"font-weight: bold;">À :</span></stro=
ng>
<br
/><strong><span style=3D"font-weight=
: bold;">Envoyé le :</span></strong> Mercredi, 10 Décembre 20=
08, 12h14mn 29s<br /><strong><span style=3D"font-weight: bold;">Objet :</sp=
an></strong> Re: [cgal-discuss] A problem with iso oriented box intersectio=
n package<br /></span><br /> hi Hichem,<br /> <br /> that is tricky indeed =
- have already encountered this issue which was solved with the help of An=
dreas Fabri.<br /> <br /> I send you my self_intersect global function, whi=
ch takes as parameters a CGAL polyhedron, and an output iterator where I wr=
ite all triangles which interesect. as you can see I can pass to the inters=
ection engine a class Intersect_facets with a parameterized constructor.<br=
/> <br /> the callback function is the operator () of that class.<br /> <b=
r /> good luck!<br /> <br /> pierre<br /> <br /> <br /> BBB HHH a éc=
rit :
<blockquote>
<div style=3D"font-family: times new roman,new york,times,serif; font-size:=
14pt;">
<div style=3D"font-family: times new roman,new york,times,serif; font-size:=
14pt;">
<div style=3D"font-family: times new roman,new york,times,serif; font-size:=
12pt;"><span style=3D"font-family: Default Sans Serif,Verdana,Arial,Helvet=
ica,sans-serif; font-size: x-small;">Hello,<br /> <br /> I am working with =
the CGAL::box_self_intersection_d to detect interrsections in a list of bbo=
xes of triangles. I want to do this in an object oriented manner (inside a =
class). Some parts of my code are listed below. I can not compile my progra=
m since there are several errors in the line using </span><span style=3D"fo=
nt-family: Default Sans Serif,Verdana,Arial,Helvetica,sans-serif; font-size=
: x-small;">box_self_intersection_d.<br /> I think the error is the use of =
the callback of </span><span style=3D"font-family: Default Sans Serif,Verda=
na,Arial,Helvetica,sans-serif; font-size: x-small;">box_self_intersection_d=
=2E In my program this callback is a class member function. In the examples=
provided by CGAL. The callback is a global function and the </span><span s=
tyle=3D"font-family: Default Sans Serif,Verdana,Arial,Helvetica,sans-serif;=
font-size: x-small;">box_self_intersection_d function is called inside mai=
n(). Can someone help me to detect the problem (how to put a function objec=
t inside a class template and how to use it correctly).</span> I tried a gl=
obal function as a callback, the compile succeds but i can not acces the me=
mber data of my class.<br /> <br /> Thanks in advance<br /> Hichem BARKI<br=
/> <br /> <span style=3D"font-family: Default Sans Serif,Verdana,Arial,Hel=
vetica,sans-serif; font-size: x-small;"><br /> #include <br /> #include <br=
/> #include <br /> #include <br /> #include <br /> #include <br /> #includ=
e <br /> <br /> <br /> using std::cout;<br /> using std::cin;<br /> using s=
td::endl;<br /> <br /> template <br /> class My_class<br /> {<br /> public:=
<br /> typedef typename Kernel::FT =
Number_type;<br /> typedef typename Kernel::Point_2 =
Point_2;<br /> typedef typename Kernel::Point_3 =
Point_3;<br /> typedef typename std::list< Triang=
le_3> Triangles;<br /> typedef typename T=
riangles::iterator tri_it;<br />=
<br /> typedef CGAL::Box_intersection_d::Box_with_handle_d Box;<br /> <br =
/> <br /> <br /> <br /> // Member data<br /> Triangles =
triangles; // List of the superse=
t triangles<br /> <br /> // Constructors<br /> My_class(...)<br /> {<br /> =
// Fill the list of Triangles<br /> .....<br /> <br /> }<br /> void </span>=
<span style=3D"font-family: Default Sans Serif,Verdana,Arial,Helvetica,sans=
-serif; font-size: x-small;">callback</span>(const& Box a, const Box&am=
p; b)<br /> {<br /> // DO some processing with the member data of My_class<=
br /> }<br /> <span style=3D"font-family: Default Sans Serif,Verdana,Arial,=
Helvetica,sans-serif; font-size: x-small;"> void get_inters_bboxes()<br /> =
{<br /> // Create the corresponding vector of bounding boxes<br /> std::vec=
tor boxes;<br /> for (tri_it iter =3D triangles.begin(); iter !=3D triangle=
s.end(); ++iter)<br /> boxes.push_back( Box( iter->bbox(), iter));<br />=
<br /> // Run the self intersection algorithm with all defaults<br /> CGAL=
::box_self_intersection_d(boxes.begin(), boxes.end(), callback, 10, CGAL::B=
ox_intersection_d::HALF_OPEN);<br /> }<br /> <br /> <br /> };<br /> <br /> =
<br /> </span></div>
</div>
</div>
<br /></blockquote>
<br /> <br />
<pre class=3D"moz-signature">-- <br />Pierre Alliez<br />INRIA Sophia Antip=
olis - Mediterranee <br />Project-team GEOMETRICA <br /><a class=3D"moz-txt=
-link-freetext" rel=3D"nofollow" href=3D"http://www-sop.inria.fr/members/Pi=
erre.Alliez/" target=3D"_blank">http://www-sop.inria.fr/members/Pierre.Alli=
ez/</a>
Tel: +33 4 92 38 76 77
Fax: +33 4 97 15 53 95
</pre>
</div>
</div>
</div>
<br /></blockquote>
--=_abaa58435ed1bfb9f1c74434826d3a3a--
- Re: Re : [cgal-discuss] A problem with iso oriented box intersection, andreas . fabri, 12/11/2008
Archive powered by MHonArc 2.6.16.