/** * \file internal/cgal_knn.h * \brief manipulation of text, and Interconversion between text and numbers * Copyright 2007-2013 IMP Inventors. All rights reserved. */ #include #ifdef IMP_HAS_BOOST_TR1_BUG #define BOOST_HAS_GCC_TR1 #include #if defined(BOOST_HAS_GCC_TR1) && defined(BOOST_HAS_INCLUDE_NEXT) #undef BOOST_HAS_INCLUDE_NEXT #endif #endif IMP_GCC_PRAGMA(diagnostic ignored "-Wuninitialized") #include #include #include #include #include #include #include #include #include IMPCGAL_BEGIN_INTERNAL_NAMESPACE template void refine_unit_sphere_cover_d(base::Vector > &ret, bool ALL) { unsigned int n= ret.size(); typedef ::CGAL::Cartesian_d< ::CGAL::Lazy_exact_nt< ::CGAL::Gmpq> > K; typedef typename K::Point_d P; typedef ::CGAL::Convex_hull_d CH; typedef ::CGAL::Optimisation_d_traits_d Traits; typedef ::CGAL::Min_sphere_d Min_sphere; std::map indexes; for (unsigned int rep=0; rep< 10*D; ++rep) { CH ch(D); for (unsigned int i=0; i< ret.size(); ++i) { P p(D, ret[i].coordinates_begin(), ret[i].coordinates_end()); typename CH::Vertex_handle vh=ch.insert(p); indexes[vh]= i+1; if (!ALL) { algebra::VectorD nr=-ret[i]; P p(D, nr.coordinates_begin(), nr.coordinates_end()); typename CH::Vertex_handle vh=ch.insert(p); indexes[vh]= -static_cast(i)-1; } } base::Vector > sums(n, algebra::get_zero_vector_d()); Floats counts(n, 0); for (CH::Facet_iterator it= ch.facets_begin(); it != ch.facets_end(); ++it) { for (unsigned int i=0; i< D; ++i ) { int vi=indexes[ch.vertex_of_facet(it, i)]; algebra::VectorD pi; if (vi > 0) { pi= ret[vi-1]; } else { continue; } /*vector > simplex; for (unsigned int j=0; i< D; ++i ) { int vj=indexes[ch.vertex_of_facet(it, j)]; VectorD pj; if (vj > 0) { pj= ret[vj-1]; } else { pj= ret[-vj+1]; } simplex.push_back((pj-pi).get_unit_vector()); } double w= simplex_volume(simplex);*/ for (unsigned int j=0; i< D; ++i ) { if (i==j) continue; int vj=indexes[ch.vertex_of_facet(it, j)]; algebra::VectorD pj; if (vj > 0) { pj= ret[vj-1]; } else { pj= ret[-vj-1]; } double d=(pj-pi).get_magnitude(); if (counts[vi-1] < d) { counts[vi-1]=d; sums[vi-1]=pj; } } } } for (unsigned int i=0; i< (ALL?2*D:D); ++i) { sums[i]=ret[i]; } for (unsigned int i=(ALL?2*D:D); i(algebra::get_unit_sphere_d()); } } std::swap(sums, ret); } } void refine_unit_sphere_cover_4d(base::Vector > &ret, bool ALL) { refine_unit_sphere_cover_d(ret, ALL); } IMPCGAL_END_INTERNAL_NAMESPACE