Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] CGAL::Null_tag to non-scalar type CGAL::Object
- Date: Wed, 13 Apr 2011 08:52:43 +0200
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=F036g6wp/1UllifdP4ut6lmEc0m6pRLbavjmudngRPsPCHn5bSJH/NXVrfOpwe6DQp vDQ35chOr/o0wy9Can8TBLmSTTd3qWIlClwfRV9riUOelGRUEKOe27KgT228IvNzzTAR eO4O+gvBjoaloJjkecTKQOPgup9U9YvCcw4YA=
Use the functor version, it will be safer.
You can do:
Kernel::Intersect_3 inter = Kernel().intersect_3_object();
Kernel::Do_intersect_3 do_inter = Kernel().do_intersect_3_object();
Then call CGAL::Object inter(sg1,sg2);
The problem is coming from a too general overload of intersection
function that has been added. Anyway I think for derived objects, using
functor is the best way to proceed as the Kernel is then specified and
you should not have problem then.
S.
On 04/12/2011 07:48 PM, S. Gerace wrote:
class Segment_2D : public CGAL::Segment_2
{
public:
// Constructs a new Segment2D with a given start and end coordinates
inline Segment_2D(const CGAL::Point_2&p,
const CGAL::Point_2&q)
: CGAL::Segment_2(p, q) { }
};
void CgalInheritanceTest()
{
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
// Using CGAL classes with CGAL::intersection works fine
CGAL::Segment_2 s1(CGAL::Point_2(0,0), CGAL::Point_2(1,1));
CGAL::Segment_2 s2(CGAL::Point_2(0,0.5), CGAL::Point_2(1,0.5));
bool doesIntersect = CGAL::do_intersect(s1, s2);
CGAL::Object result = CGAL::intersection(s1, s2);
std::cout<< "Did intersect: "<< doesIntersect<< std::endl;
std::cout<< "Found intersection: "<< !(result.is_empty())<<
std::endl<< std::endl;
// Using child classes of CGAL classes with CGAL::intersection does not
work
Segment_2D sg1(CGAL::Point_2(0,0), CGAL::Point_2(1,1));
Segment_2D sg2(CGAL::Point_2(0,0.5), CGAL::Point_2(1,0.5));
bool doesIntersect2 = CGAL::do_intersect(sg1, sg2); // This call works
fine
CGAL::Object result2 = CGAL::intersection(sg1, sg2); // Compile error:
conversion from CGAL::Null_tag to non-scalar type CGAL::Object with CGAL 3.7
std::cout<< "Did intersect: "<< doesIntersect2<< std::endl;
std::cout<< "Found intersection: "<< !(result2.is_empty())<<
std::endl;
}
- [cgal-discuss] CGAL::Null_tag to non-scalar type CGAL::Object, S. Gerace, 04/12/2011
- Re: [cgal-discuss] CGAL::Null_tag to non-scalar type CGAL::Object, Sebastien Loriot (GeometryFactory), 04/13/2011
- [cgal-discuss] Re: CGAL::Null_tag to non-scalar type CGAL::Object, S. Gerace, 04/13/2011
- Re: [cgal-discuss] CGAL::Null_tag to non-scalar type CGAL::Object, Sebastien Loriot (GeometryFactory), 04/13/2011
Archive powered by MHonArc 2.6.16.