Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Question about intersection(A,B)

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Question about intersection(A,B)


Chronological Thread 
  • From: Mahmood Naderan <>
  • To:
  • Subject: Re: [cgal-discuss] Question about intersection(A,B)
  • Date: Sun, 8 Jun 2008 03:22:45 -0700 (PDT)
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Message-ID; b=pU/9iiTL6XKzosVrWrrQHsUiInLQAKsWCDeiwp9C52geZ6QVTM+yD34eyHBEMwoRb03gnAjrhMW1E46ROHtMJws5XNxITSZUYp8pa8ORbLJ+tOAnH+nRCSr4Asp4LOHXX4/LiuVMxga+fFdF8wyjd8d6yXSJZCzEZy1SeSmkq4k=;

>  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,


-------------------
Mahmood Naderan
  
 

 
----- Original Message ----
From: Laurent Rineau <>
To:
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




Archive powered by MHonArc 2.6.16.

Top of Page