Hello,
I have a problem with "intersection" function. This is my class: template <class Traits_, class AppKernel_>
class my_class { public: typedef Traits_ Traits_2;
typedef AppKernel_ Approx_kernel; typedef typename Approx_kernel::Point_2 App_point_2; typedef typename Approx_kernel::Segment_2 App_segment_2; ... } and I have these in one one of my functions (I have put somethings in segList and app_bound_segs list and they have no problem):
typename std::list<App_segment_2>::const_iterator sit1, sit2;
std::list< App_point_2 > interPoints; std::list< App_segment_2 > app_bound_segs, segList; interPoints.clear(); for ( sit1 = segList.begin(); sit1 != segList.end(); sit1++ ) for ( sit2 = app_bound_segs.begin(); sit2 != app_bound_segs.end(); sit2++ ) interPoints.push_back( CGAL::intersection( sit1, sit2 ) ); when I compile, it says: error C2784: 'CGAL::Object CGAL::intersection(const CGAL::Triangle_2<R_> &,const CGAL::Iso_rectangle_2<R_> &)' : could not deduce template argument for 'const CGAL::Triangle_2<R_> &' from 'std::list<_Ty>::_Const_iterator<_Secure_validation>' what does the error mean? I read in manual that
Object intersection( Type1<Kernel> obj1, Type2<Kernel> obj2); so what is the problem?
Thanks, |
On Sunday 08 June 2008 10:56:06 Mahmood Naderan wrote:
> Hello, > I have a problem with "intersection" function. This is my class: > template <class Traits_, class AppKernel_> > class my_class > { > public: > typedef Traits_ Traits_2; > typedef AppKernel_ Approx_kernel; > > typedef typename Approx_kernel::Point_2 App_point_2; > typedef typename Approx_kernel::Segment_2 App_segment_2; > ... > } > and I have these in one one of my functions (I have put somethings in > segList and app_bound_segs list and they have no problem): typename > std::list<App_segment_2>::const_iterator sit1, sit2; std::list< > App_point_2 > interPoints; > std::list< App_segment_2 > app_bound_segs, segList; > interPoints.clear(); > > for ( sit1 = segList.begin(); sit1 != segList.end(); sit1++ ) > for ( sit2 = app_bound_segs.begin(); sit2 != app_bound_segs.end(); sit2++ > ) interPoints.push_back( CGAL::intersection( sit1, sit2 ) ); > > > when I compile, it says: > error C2784: 'CGAL::Object CGAL::intersection(const CGAL::Triangle_2<R_> > &,const CGAL::Iso_rectangle_2<R_> &)' : could not deduce template argument > for 'const CGAL::Triangle_2<R_> &' from > 'std::list<_Ty>::_Const_iterator<_Secure_validation>' what does the error > mean? I read in manual that > Object intersection( Type1<Kernel> obj1, Type2<Kernel> obj2); > so what is the problem? You are calling CGAL::intersection with two iterators! CGAL::intersection deals with CGAL objects (Triangle_3, Segment_3, for example) and not with iterators to CGAL objects. Replace the following (incorrect) call: CGAL::intersection( sit1, sit2 ) with a more correct one: CGAL::intersection( *sit1, *sit2 ); What it more, CGAL::intersection return type is CGAL::Object, and not Point_3 (which makes not sens, in the general case). Your piece of code does not deal with pair of non-intersecting segments! Here is a more correct version: for ( sit1 = segList.begin(); sit1 != segList.end(); sit1++ ) for ( sit2 = app_bound_segs.begin(); sit2 != app_bound_segs.end(); sit2++ ) { CGAL::Object inter_object = CGAL::intersection( *sit1, *sit2 ); // inter_object is castable to Point_3 if and only if the intersection // is non-empty, and is not a segment (that is if the intersection is // a point if( const Point_3* inter_point = CGAL::object_cast<Point_3>(&inter_object) ) { interPoints.push_back( *inter_point ); } } -- Laurent Rineau INRIA - Sophia Antipolis BP 93, 2004 Route des Lucioles 06902 Sophia Antipolis Cedex FRANCE Tel: +33 4 92 38 78 62 (Fax: +33.4.97.15.53.95) -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://lists-sop.inria.fr/wws/info/cgal-discuss |
In reply to this post by Mahmood Naderan
> CGAL::intersection( *sit1, *sit2 );
> CGAL::Object inter_object = CGAL::intersection( *sit1, *sit2 ); I tried both your solutions, but they have one compiler error:
error C2784: 'CGAL::Object CGAL::intersection(const CGAL::Triangle_2<R_> &,const CGAL::Iso_rectangle_2<R_> &)' : could not deduce template argument for 'const CGAL::Triangle_2<R_> &' from 'const CGAL::Approximated_Cartesian<NT_,Compare_NT_,Sqrt_NT_>::Segment_2'
with [ NT_=double, Compare_NT_=Compare_double_eps, Sqrt_NT_=Square_root_eps ]
Regards, ----- Original Message ---- From: Laurent Rineau <[hidden email]> To: [hidden email] Sent: Sunday, June 8, 2008 12:53:27 PM Subject: Re: [cgal-discuss] Question about intersection(A,B) On Sunday 08 June 2008 10:56:06 Mahmood Naderan wrote: > Hello, > I have a problem with "intersection" function. This is my class: > template <class Traits_, class AppKernel_> > class my_class > { > public: > typedef Traits_ Traits_2; > typedef AppKernel_ Approx_kernel; > > typedef typename Approx_kernel::Point_2 App_point_2; > typedef typename Approx_kernel::Segment_2 App_segment_2; > ... > } > and I have these in one one of my functions (I have put somethings in > segList and app_bound_segs list and they have no problem): typename > std::list<App_segment_2>::const_iterator sit1, sit2; std::list< > App_point_2 > interPoints; > std::list< App_segment_2 > app_bound_segs, segList; > interPoints.clear(); > > for ( sit1 = segList.begin(); sit1 != segList.end(); sit1++ ) > for ( sit2 = app_bound_segs.begin(); sit2 != app_bound_segs.end(); sit2++ > ) interPoints.push_back( CGAL::intersection( sit1, sit2 ) ); > > > when I compile, it says: > error C2784: 'CGAL::Object CGAL::intersection(const CGAL::Triangle_2<R_> > &,const CGAL::Iso_rectangle_2<R_> &)' : could not deduce template argument > for 'const CGAL::Triangle_2<R_> &' from > 'std::list<_Ty>::_Const_iterator<_Secure_validation>' what does the error > mean? I read in manual that > Object intersection( Type1<Kernel> obj1, Type2<Kernel> obj2); > so what is the problem? You are calling CGAL::intersection with two iterators! CGAL::intersection deals with CGAL objects (Triangle_3, Segment_3, for example) and not with iterators to CGAL objects. Replace the following (incorrect) call: CGAL::intersection( sit1, sit2 ) with a more correct one: CGAL::intersection( *sit1, *sit2 ); What it more, CGAL::intersection return type is CGAL::Object, and not Point_3 (which makes not sens, in the general case). Your piece of code does not deal with pair of non-intersecting segments! Here is a more correct version: for ( sit1 = segList.begin(); sit1 != segList.end(); sit1++ ) for ( sit2 = app_bound_segs.begin(); sit2 != app_bound_segs.end(); sit2++ ) { CGAL::Object inter_object = CGAL::intersection( *sit1, *sit2 ); // inter_object is castable to Point_3 if and only if the intersection // is non-empty, and is not a segment (that is if the intersection is // a point if( const Point_3* inter_point = CGAL::object_cast<Point_3>(&inter_object) ) { interPoints.push_back( *inter_point ); } } -- Laurent Rineau INRIA - Sophia Antipolis BP 93, 2004 Route des Lucioles 06902 Sophia Antipolis Cedex FRANCE Tel: +33 4 92 38 78 62 (Fax: +33.4.97.15.53.95) -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://lists-sop.inria.fr/wws/info/cgal-discuss |
On Sunday 08 June 2008 12:22:45 Mahmood Naderan wrote:
> I tried both your solutions, but they have one compiler error: > error C2784: 'CGAL::Object CGAL::intersection(const CGAL::Triangle_2<R_> > &,const CGAL::Iso_rectangle_2<R_> &)' : could not deduce template argument > for 'const CGAL::Triangle_2<R_> &' from 'const > CGAL::Approximated_Cartesian<NT_,Compare_NT_,Sqrt_NT_>::Segment_2' with > [ > NT_=double, > Compare_NT_=Compare_double_eps, > Sqrt_NT_=Square_root_eps > ] As far as I know, CGAL::Approximated_Cartesian is not a CGAL class. If you create a custom kernel, with custom Segment_2 or Point_2 subtype, you cannot except that the CGAL::intersection template can deal with those types! Well, maybe it can. At this point, if you want to get help, you'll need to give us your complete code. If your code is bigger that 2-5ko, you should not attached it to a mail to a mailing list, but put it on the web (accessible with http of ftp, for example). Anyway, it seems that you should *really* read the documentation! For example, the documentation of CGAL::intersection is here: http://www.cgal.org/Manual/3.3/doc_html/cgal_manual/Kernel_23_ref/Function_intersection.html On that reference page, you can see two informations that you missed: - the return type of CGAL::intersection is always CGAL::Object, - that function can take a couple a CGAL::Segment_2<K> objects, as soon as K is a model of Kernel concept¹. Your Segment_2 does not seem to be an instance of CGAL::Segment_2<K>. The error you get, for the moment, is for that reason! ¹) The Kernel concept is documented here: http://www.cgal.org/Manual/3.3/doc_html/cgal_manual/Kernel_23_ref/Concept_Kernel.html Good reading. -- Laurent Rineau INRIA - Sophia Antipolis BP 93, 2004 Route des Lucioles 06902 Sophia Antipolis Cedex FRANCE Tel: +33 4 92 38 78 62 (Fax: +33.4.97.15.53.95) -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://lists-sop.inria.fr/wws/info/cgal-discuss |
In reply to this post by Mahmood Naderan
>Well, maybe it can. At this point, if you want to get help, you'll need to
>give us your complete code. If your code is bigger that 2-5ko, you should not >attached it to a mail to a mailing list, but put it on the web (accessible >with http of ftp, for example). The code is on http://ifile.it/ej9wkga . I have to say that it works with 3.2.1 version. It has a custom approximated kernel but I didn't create it. I also will try to see if it is possible to convert this kernel to some standard CGAL kernels (some basic types that I use).
Thanks,
----- Original Message ---- From: Laurent Rineau <[hidden email]> To: [hidden email] Sent: Sunday, June 8, 2008 2:13:56 PM Subject: Re: [cgal-discuss] Question about intersection(A,B) On Sunday 08 June 2008 12:22:45 Mahmood Naderan wrote: > I tried both your solutions, but they have one compiler error: > error C2784: 'CGAL::Object CGAL::intersection(const CGAL::Triangle_2<R_> > &,const CGAL::Iso_rectangle_2<R_> &)' : could not deduce template argument > for 'const CGAL::Triangle_2<R_> &' from 'const > CGAL::Approximated_Cartesian<NT_,Compare_NT_,Sqrt_NT_>::Segment_2' with > [ > NT_=double, > Compare_NT_=Compare_double_eps, > Sqrt_NT_=Square_root_eps > ] As far as I know, CGAL::Approximated_Cartesian is not a CGAL class. If you create a custom kernel, with custom Segment_2 or Point_2 subtype, you cannot except that the CGAL::intersection template can deal with those types! Well, maybe it can. At this point, if you want to get help, you'll need to give us your complete code. If your code is bigger that 2-5ko, you should not attached it to a mail to a mailing list, but put it on the web (accessible with http of ftp, for example). Anyway, it seems that you should *really* read the documentation! For example, the documentation of CGAL::intersection is here: http://www.cgal.org/Manual/3.3/doc_html/cgal_manual/Kernel_23_ref/Function_intersection.html On that reference page, you can see two informations that you missed: - the return type of CGAL::intersection is always CGAL::Object, - that function can take a couple a CGAL::Segment_2<K> objects, as soon as K is a model of Kernel concept¹. Your Segment_2 does not seem to be an instance of CGAL::Segment_2<K>. The error you get, for the moment, is for that reason! ¹) The Kernel concept is documented here: http://www.cgal.org/Manual/3.3/doc_html/cgal_manual/Kernel_23_ref/Concept_Kernel.html Good reading. -- Laurent Rineau INRIA - Sophia Antipolis BP 93, 2004 Route des Lucioles 06902 Sophia Antipolis Cedex FRANCE Tel: +33 4 92 38 78 62 (Fax: +33.4.97.15.53.95) -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://lists-sop.inria.fr/wws/info/cgal-discuss |
Free forum by Nabble | Edit this page |