Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Using user defined field Number Type in CGAL

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Using user defined field Number Type in CGAL


Chronological Thread 
  • From: Marc Glisse <>
  • To:
  • Subject: Re: [cgal-discuss] Using user defined field Number Type in CGAL
  • Date: Fri, 4 Mar 2016 23:17:10 +0100 (CET)

On Fri, 4 Mar 2016, Indranil Chowdhury wrote:

I am new to the CGAL mailing list. I am playing with CGAL triangulation
lately, and am trying to use my own double number type to pass to CGAL and
want all computations that the CGAL kernel does to use this only (specially
the comparison operators). Currently I am not concerned with speed, but
want the kernel to interprete anything less than a threshold to be zero.

Code :

#include <boost\operators.hpp>

Ah, windows...

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

//a number type to overload all floating point operations
struct myDouble : boost::operators<myDouble>
{
double val;

myDouble( double f )
{val = f;}
myDouble( const myDouble &f ):
val(f.val){}

//arithmetic operators...

//logical operators
bool operator<(const myDouble &other ) const
{
bool isEqual = (std::abs(val-other.val) < c_zero);//c_zero is a given
threshold
return ( !isEqual && val<other.val );
}
bool operator==(const myDouble &other ) const
{
return ( std::abs(val-other.val) < c_zero );
}
};

///From definition of inexact kernels
namespace CGAL
{
// A modification of inexact kernel from CGAL
class Epick_cgal2DSurf
: public Filtered_kernel_adaptor<
Type_equality_wrapper<
Simple_cartesian<myDouble>::Base<Epick_cgal2DSurf>::Type, Epick_cgal2DSurf
,
#ifdef CGAL_NO_STATIC_FILTERS
false >
#else
true >
#endif
{
};
}

I get compilation error :

Error 1 error C2440: '<function-style-cast>' : cannot convert from
'const CgalDouble' to 'CGAL::Gmpq'
E:\AnsysDev\3rdparty\CGAL\CGAL-4.4\include\CGAL\NT_converter.h 41

and I am not sure how to get this code to compile.

My questions are:
1. Is there any way for CGAL to accept this numberType and get it compiled?
2. Is there any other way to tell CGAL that any quantity less than
specified is zero?

It isn't clear what you are hoping to achieve. Probably you are looking for the kernel Simple_cartesian<myDouble>, but I am not sure. Filtered_kernel implements all predicates by converting coordinates to intervals, evaluating using intervals, and if that doesn't give the answer, it converts to an expensive exact type (Gmpq here) and evaluates again. Your number type is not convertible to intervals and Gmpq so it cannot use Filtered_kernel.

--
Marc Glisse



Archive powered by MHonArc 2.6.18.

Top of Page