示例#1
0
void AT_coercion_test_for_cgal_types_rat(){
    
    AT_coercion_test_for_cgal_types_int<AT>();

    typedef typename AT::Integer Integer;
    typedef typename AT::Rational Rational;
    typedef typename AT::Bigfloat_interval Bigfloat_interval; 

    CGAL_USE_TYPE(Bigfloat_interval);
    CGAL_static_assertion(!(::boost::is_same<Integer, CGAL::Null_tag>::value));
    CGAL_static_assertion(!(::boost::is_same<Rational, CGAL::Null_tag>::value));
    CGAL_static_assertion(!(::boost::is_same<Bigfloat_interval, CGAL::Null_tag>::value));

    CGAL::test_explicit_interoperable_from_to<int     ,Rational>();
    CGAL::test_explicit_interoperable_from_to<double  ,Rational>();
    CGAL::test_implicit_interoperable_from_to<Integer ,Rational>();
    CGAL::test_implicit_interoperable_from_to<Rational,Rational>();
    CGAL::test_explicit_interoperable_from_to<Rational,Interval>();

    
    typedef CGAL::Sqrt_extension<Integer  , Integer> Extn_1;  
    typedef CGAL::Sqrt_extension<Extn_1   , Extn_1 > Extn_2n;
    CGAL_USE_TYPE(Extn_2n);
    typedef CGAL::Sqrt_extension<Extn_1   , Integer> Extn_2d;
    CGAL_USE_TYPE(Extn_2d);

    typedef CGAL::Sqrt_extension<Rational  , Integer> Extn_rat_int; 
    CGAL::test_explicit_interoperable_from_to<int         ,Extn_rat_int>();
//  CGAL::test_explicit_interoperable_from_to<double      ,Extn_rat_int>();
    CGAL::test_explicit_interoperable_from_to<Integer     ,Extn_rat_int>();
    CGAL::test_explicit_interoperable_from_to<Rational    ,Extn_rat_int>();
    CGAL::test_explicit_interoperable_from_to<Extn_1      ,Extn_rat_int>();
    CGAL::test_explicit_interoperable_from_to<Extn_rat_int,Extn_rat_int>();
        
    typedef CGAL::Sqrt_extension<Rational  , Rational> Extn_rat_1;
    CGAL::test_explicit_interoperable_from_to<int         ,Extn_rat_1>();
//  CGAL::test_explicit_interoperable_from_to<double      ,Extn_rat_1>();
    CGAL::test_explicit_interoperable_from_to<Integer     ,Extn_rat_1>();
    CGAL::test_explicit_interoperable_from_to<Rational    ,Extn_rat_1>();
//  CGAL::test_explicit_interoperable_from_to<Extn_1      ,Extn_rat_1>();
    CGAL::test_explicit_interoperable_from_to<Extn_rat_1,Extn_rat_1>();

    typedef CGAL::Sqrt_extension<Extn_rat_1, Extn_rat_1 > Extn_rat_2n;
    CGAL::test_explicit_interoperable_from_to<int         ,Extn_rat_2n>();
//  CGAL::test_explicit_interoperable_from_to<double      ,Extn_rat_2n>();
    CGAL::test_explicit_interoperable_from_to<Integer     ,Extn_rat_2n>();
    CGAL::test_explicit_interoperable_from_to<Rational    ,Extn_rat_2n>();
    CGAL::test_explicit_interoperable_from_to<Extn_rat_1  ,Extn_rat_2n>();
    CGAL::test_explicit_interoperable_from_to<Extn_rat_2n ,Extn_rat_2n>();

    typedef CGAL::Sqrt_extension<Extn_rat_1, Rational> Extn_rat_2d;
    CGAL::test_explicit_interoperable_from_to<int         ,Extn_rat_2d>();
//  CGAL::test_explicit_interoperable_from_to<double      ,Extn_rat_2d>();
    CGAL::test_explicit_interoperable_from_to<Integer     ,Extn_rat_2d>();
    CGAL::test_explicit_interoperable_from_to<Rational    ,Extn_rat_2d>();
    CGAL::test_explicit_interoperable_from_to<Extn_rat_1  ,Extn_rat_2d>();
    CGAL::test_explicit_interoperable_from_to<Extn_rat_2d ,Extn_rat_2d>();    
}
示例#2
0
void AT_coercion_test_for_cgal_types_fws(){
    AT_coercion_test_for_cgal_types_rat<AT>();
    
    typedef typename AT::Integer Integer;
    typedef typename AT::Rational Rational;    
    typedef typename AT::Bigfloat_interval Bigfloat_interval;
    typedef typename AT::Field_with_sqrt Real;

    CGAL_USE_TYPE(Bigfloat_interval);
    CGAL_static_assertion(!(::boost::is_same<Integer, CGAL::Null_tag>::value));
    CGAL_static_assertion(!(::boost::is_same<Rational, CGAL::Null_tag>::value));
    CGAL_static_assertion(!(::boost::is_same<Bigfloat_interval, CGAL::Null_tag>::value));
    CGAL_static_assertion(!(::boost::is_same<Real, CGAL::Null_tag>::value));


    typedef CGAL::Sqrt_extension<Integer  , Integer> Extn_1;  
    typedef CGAL::Sqrt_extension<Extn_1   , Extn_1 > Extn_2n;
    typedef CGAL::Sqrt_extension<Extn_1   , Integer> Extn_2d;

    typedef CGAL::Sqrt_extension<Rational  , Integer>     Extn_rat_int; 
    typedef CGAL::Sqrt_extension<Rational  , Rational>    Extn_rat_1;
    typedef CGAL::Sqrt_extension<Extn_rat_1, Extn_rat_1 > Extn_rat_2n;
    typedef CGAL::Sqrt_extension<Extn_rat_1, Rational>    Extn_rat_2d; 
    
    CGAL::test_explicit_interoperable_from_to<int         ,Real>();
    CGAL::test_explicit_interoperable_from_to<double      ,Real>();
    CGAL::test_explicit_interoperable_from_to<Integer     ,Real>();
    CGAL::test_explicit_interoperable_from_to<Rational    ,Real>();
    CGAL::test_explicit_interoperable_from_to<Extn_1      ,Real>();
    CGAL::test_explicit_interoperable_from_to<Extn_2n     ,Real>();
    CGAL::test_explicit_interoperable_from_to<Extn_2d     ,Real>();
    CGAL::test_explicit_interoperable_from_to<Extn_rat_int,Real>();
    CGAL::test_explicit_interoperable_from_to<Extn_rat_1  ,Real>();
    CGAL::test_explicit_interoperable_from_to<Extn_rat_2n ,Real>();
    CGAL::test_explicit_interoperable_from_to<Extn_rat_2d ,Real>();

  // direct casts 
  // Integer;
    CGAL::test_explicit_interoperable_from_to<Integer,Interval>();
  
  // Rational
    CGAL::test_explicit_interoperable_from_to<Rational,Interval>();
  
  // Interval
    CGAL::test_explicit_interoperable_from_to<Interval,Interval>();
}
示例#3
0
int main(){
    typedef CGAL::Fraction_traits<CGAL::Gmpq> FT;
    typedef FT::Numerator_type Numerator_type;
    typedef FT::Denominator_type Denominator_type;

    CGAL_static_assertion((boost::is_same<Numerator_type,CGAL::Gmpz>::value));
    CGAL_static_assertion((boost::is_same<Denominator_type,CGAL::Gmpz>::value));

    Numerator_type numerator;
    Denominator_type denominator;
    CGAL::Gmpq fraction(4,5);
    FT::Decompose()(fraction,numerator,denominator);

    CGAL::set_pretty_mode(std::cout);
    std::cout << "decompose fraction: "<< std::endl;
    std::cout << "fraction   : " << fraction << std::endl;
    std::cout << "numerator  : " << numerator<< std::endl;
    std::cout << "denominator: " << denominator << std::endl;

    std::cout << "re-compose fraction: "<< std::endl;
    fraction = FT::Compose()(numerator,denominator);
    std::cout << "fraction   : " << fraction << std::endl;
}
  void image() const
  {
    typedef CGAL::Image_3 Image;
    typedef CGAL::Labeled_image_mesh_domain_3<Image, K_e_i> Mesh_domain;

    typedef typename CGAL::Mesh_triangulation_3<
      Mesh_domain,
      CGAL::Kernel_traits<Mesh_domain>::Kernel,
      Concurrency_tag>::type Tr;
    typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;

    typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;
    typedef typename Mesh_criteria::Facet_criteria Facet_criteria;
    typedef typename Mesh_criteria::Cell_criteria Cell_criteria;

    //-------------------------------------------------------
    // Data generation
    //-------------------------------------------------------
    Image image;
    image.read("data/liver.inr.gz");

    std::cout << "\tSeed is\t"
      << CGAL::get_default_random().get_seed() << std::endl;
    Mesh_domain domain(image, 1e-9, &CGAL::get_default_random());

    // Set mesh criteria
    Facet_criteria facet_criteria(25, 20*image.vx(), 5*image.vx());
    Cell_criteria cell_criteria(4, 25*image.vx());
    Mesh_criteria criteria(facet_criteria, cell_criteria);

    // Mesh generation
    C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria,
                                        CGAL::parameters::no_exude(),
                                        CGAL::parameters::no_perturb());

    // Verify
    this->verify_c3t3_volume(c3t3, 1772330*0.95, 1772330*1.05);
    this->verify(c3t3,domain,criteria, Bissection_tag());

    typedef typename Mesh_domain::Surface_patch_index Patch_id;
    CGAL_static_assertion(CGAL::Output_rep<Patch_id>::is_specialized);
    CGAL_USE_TYPE(Patch_id);
  }
示例#5
0
int main(){
    {
        typedef CGAL::Algebraic_extension_traits<int> AET;
    
        typedef AET::Type Type;
        CGAL_USE_TYPE(Type);
        CGAL_static_assertion((::boost::is_same<int,Type>::value)); 

        typedef AET::Is_extended Is_extended;
        CGAL_USE_TYPE(Is_extended);
        CGAL_static_assertion(
                (::boost::is_same<CGAL::Tag_false,Is_extended>::value));
    
        typedef AET::Normalization_factor Normalization_factor; 
        {
            typedef Normalization_factor::argument_type argument_type;
            CGAL_USE_TYPE(argument_type);
            CGAL_static_assertion((::boost::is_same<argument_type,int>::value));
            typedef Normalization_factor::result_type result_type;
            CGAL_USE_TYPE(result_type);
            CGAL_static_assertion((::boost::is_same<result_type,int>::value));
            Normalization_factor nfac;
            assert(nfac(3)==1);
        }
        typedef AET::Denominator_for_algebraic_integers DFAI; 
        {
            typedef DFAI::argument_type argument_type;
            CGAL_USE_TYPE(argument_type);
            CGAL_static_assertion((::boost::is_same<argument_type,int>::value));
            typedef DFAI::result_type result_type;
            CGAL_USE_TYPE(result_type);
            CGAL_static_assertion((::boost::is_same<result_type,int>::value));
            DFAI dfai;
            assert(dfai(3)==1);
        }
    }
    {
        typedef CGAL::Sqrt_extension<int,int> EXT; 
        typedef CGAL::Algebraic_extension_traits<EXT> AET;
    
        typedef AET::Type Type;
        CGAL_USE_TYPE(Type);
        CGAL_static_assertion((::boost::is_same<EXT,Type>::value)); 

        typedef AET::Is_extended Is_extended;
        CGAL_USE_TYPE(Is_extended);
        CGAL_static_assertion(
                (::boost::is_same<CGAL::Tag_true,Is_extended>::value));
    
        typedef AET::Normalization_factor Normalization_factor; 
        {
            typedef Normalization_factor::argument_type argument_type;
            CGAL_USE_TYPE(argument_type);
            CGAL_static_assertion((::boost::is_same<argument_type,EXT>::value));
            typedef Normalization_factor::result_type result_type;
            CGAL_USE_TYPE(result_type);
            CGAL_static_assertion((::boost::is_same<result_type,EXT>::value));
            Normalization_factor nfac;
            assert(nfac(EXT(3))==1);
            assert(nfac(EXT(3,0,5))==1);
            assert(nfac(EXT(3,1,5))==EXT(3,-1,5));
        }
        typedef AET::Denominator_for_algebraic_integers DFAI; 
        {
            typedef DFAI::argument_type argument_type;
            CGAL_USE_TYPE(argument_type);
            CGAL_static_assertion((::boost::is_same<argument_type,EXT>::value));
            typedef DFAI::result_type result_type;
            CGAL_USE_TYPE(result_type);
            CGAL_static_assertion((::boost::is_same<result_type,EXT>::value));
            DFAI dfai;
            assert(dfai(EXT(3))==1);
            assert(dfai(EXT(3,0,5))==1);
            assert(dfai(EXT(3,1,5))==20);
        }
    }
}