Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Distance from a Convex_hull_3 to Point_3

Subject: CGAL users discussion list

List archive

[cgal-discuss] Distance from a Convex_hull_3 to Point_3


Chronological Thread 
  • From: "andrea.tagliasacchi" <>
  • To:
  • Subject: [cgal-discuss] Distance from a Convex_hull_3 to Point_3
  • Date: Thu, 7 Feb 2013 09:21:06 -0800 (PST)

I have a convex hull in 3D and need to find all the points (in a set) that fall within a distance \epsilon from it, or that are in its interior (distance<0). This CGAL class seems highly related. To approach this I simply keep "P" fixed, and create a lot of dummy sets "Q" to query the distance. I have tried this solution, but it seems that I am having problems, this is a demo code:
#include "CGAL/point_generators_3.h"
#include <CGAL/Polytope_distance_d.h>
#include <CGAL/Polytope_distance_d_traits_3.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel KEPIC;
typedef CGAL::Cartesian<double>                             KCART;
//typedef KEPIC                                               KERNEL;
typedef KCART                                               KERNEL;
typedef CGAL::Creator_uniform_3<double, KERNEL::Point_3>    Creator;

void function(){
    /// Fill in source hull
    typedef CGAL::Polytope_distance_d_traits_3<K> Traits;
    CGAL::Polytope_distance_d<Traits> pd;
    CGAL::Random_points_in_sphere_3<Point_3, Creator> pgen(100);
    for (int i = 0; i < 100 ; i++, ++pgen)
        pd.insert_p(*pgen);
        
    /// Query point sets
    CGAL::Random_points_in_sphere_3<Point_3, Creator> gen(100);
    Scalar off = 10.0;
    for (int i = 0; i < 100 ; i++, ++gen){
        Point_3 p = *gen;
        Point_3 q(p.x()+off, p.y()+off, p.z()+off);
        std::vector<Point_3> qv;
        qv.push_back(q);
        pd.set_q(qv.begin(), qv.end()); // Can I use ptr arith with just 1 element? (&q, (&q)+1)?

        assert( pd.is_valid(true) );        
        
        if( pd.is_zero() )
            qDebug() << "is_zero";
        if( pd.is_finite() )
            qDebug("dist %f", pd.squared_distance());
    }
 }
for which I get a crash during set_q(...) giving the message:
basis-inverse check: failed ( row=2 | col=0 )
basis-inverse check: failed ( row=2 | col=1 )
basis-inverse check: failed ( row=3 | col=1 )
basis-inverse check: failed ( row=2 | col=2 )
basis-inverse check: failed ( row=3 | col=3 )
basis-inverse check: failed ( row=4 | col=4 )
CGAL error: assertion violation!
_expression_ : check_basis_inverse()
File       : ../../starlab-opttrans/external/CGAL-4.0.2/include/CGAL/QP_solver/QP_solver_impl.h
Line       : 1155
Explanation: 
Refer to the bug-reporting instructions at http://www.cgal.org/bug_report.html
libc++abi.dylib: terminate called throwing an exception
Note however that in a previous test the single query point was actually working. For a while I thought CGAL had problems when using a set Q which was completely inside the CHull(P). With my own data (not using generator) I was getting a fail at the is_valid. Overall... quite unstable... Thoughts? Thanks! :)
--- Andrea Tagliasacchi Ph.D. Candidate School of Computer Science Simon Fraser University


View this message in context: Distance from a Convex_hull_3 to Point_3
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.18.

Top of Page