one unsuccessful attempt to mix kernel (I tried AABB tree with Cartesian, the rest with filtered kernel)

This commit is contained in:
Pierre Alliez 2008-07-28 19:30:23 +00:00
parent 6ef5a5d693
commit bf572511a8
5 changed files with 38 additions and 35 deletions

View File

@ -82,14 +82,14 @@ void MainWindow::on_actionRemeshing_triggered()
QTime time;
time.start();
std::cout << "Build AABB tree...";
typedef CGAL::Simple_cartesian<double> Simple_cartesian_kernel;
typedef CGAL::Cartesian<double> Cartesian_kernel;
typedef CGAL::AABB_tree<GT,Polyhedron::Facet_handle,Polyhedron> Tree;
Tree tree;
tree.build_faces(*pMesh);
std::cout << "done (" << time.elapsed() << " ms)" << std::endl;
// input surface
typedef CGAL::AABB_polyhedral_oracle<Polyhedron,GT> Input_surface;
typedef CGAL::AABB_polyhedral_oracle<Polyhedron,GT,GT> Input_surface;
Input_surface input(&tree);
// initial point set
@ -97,11 +97,13 @@ void MainWindow::on_actionRemeshing_triggered()
std::cout << "Insert initial point set...";
unsigned int nb_initial_points = 10;
Polyhedron::Point_iterator it;
typedef CGAL::Cartesian_converter<Kernel,GT> Converter;
Converter convert;
unsigned int i = 0;
for(it = pMesh->points_begin();
it != pMesh->points_end(), i < nb_initial_points;
it++, i++)
tr.insert(*it);
tr.insert(convert(*it));
std::cout << "done (" << time.elapsed() << " ms)" << std::endl;
// remesh

View File

@ -11,7 +11,6 @@
#include "Polyhedron_type_fwd.h"
//typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::FT FT;
typedef Kernel::Line_3 Line;
typedef Kernel::Point_3 Point;
@ -21,7 +20,6 @@ typedef Kernel::Vector_3 Vector;
typedef Kernel::Triangle_3 Triangle;
typedef Kernel::Iso_cuboid_3 Iso_cuboid;
// struct Polyhedron : public CGAL::Polyhedron_3<Kernel> {};
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
#endif // POLYHEDRON_TYPE_H

View File

@ -3,10 +3,12 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Cartesian.h>
#include <memory>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
// typedef CGAL::Cartesian<double> Kernel;
//struct Kernel;
namespace CGAL {
class Polyhedron_items_3;

View File

@ -39,8 +39,10 @@ public:
typedef std::pair<Point, Input> Point_with_input;
typedef typename PSC::Traits PSC_kernel;
typedef typename PSC_kernel::Point_3 PSC_Point;
//typedef CGAL::Cartesian_converter<PSC_kernel, Kernel > Converter;
typedef typename PSC_kernel::Point_3 PSC_point;
typedef typename PSC_kernel::Vector_3 PSC_vector;
typedef typename PSC_kernel::Triangle_3 PSC_triangle;
typedef CGAL::Cartesian_converter<PSC_kernel, Kernel > Converter;
private:
@ -88,10 +90,9 @@ private:
Bbox compute_bbox(Input f)
{
// Converter convert;
const Point a = f->halfedge()->vertex()->point();
const Point b = f->halfedge()->next()->vertex()->point();
const Point c = f->halfedge()->next()->next()->vertex()->point();
const PSC_point a = f->halfedge()->vertex()->point();
const PSC_point b = f->halfedge()->next()->vertex()->point();
const PSC_point c = f->halfedge()->next()->next()->vertex()->point();
return a.bbox() + b.bbox() + c.bbox();
}
@ -138,15 +139,15 @@ private:
static Point centroid(Input f)
{
//Converter convert;
const Point a = f->halfedge()->vertex()->point();
const Point b = f->halfedge()->next()->vertex()->point();
const Point c = f->halfedge()->next()->next()->vertex()->point();
const PSC_point a = f->halfedge()->vertex()->point();
const PSC_point b = f->halfedge()->next()->vertex()->point();
const PSC_point c = f->halfedge()->next()->next()->vertex()->point();
// somehow CGAL::centroid does not compile
Vector u = a - CGAL::ORIGIN;
Vector v = b - CGAL::ORIGIN;
Vector w = c - CGAL::ORIGIN;
return CGAL::ORIGIN + (u + v + w) / 3.0;
PSC_vector u = a - CGAL::ORIGIN;
PSC_vector v = b - CGAL::ORIGIN;
PSC_vector w = c - CGAL::ORIGIN;
Converter convert;
return convert(CGAL::ORIGIN + (u + v + w) / 3.0);
}
template<typename Input_>
@ -330,11 +331,11 @@ public:
static Triangle triangle(Input f)
{
// Converter convert;
const Point a = f->halfedge()->vertex()->point();
const Point b = f->halfedge()->next()->vertex()->point();
const Point c = f->halfedge()->next()->next()->vertex()->point();
return Triangle(a,b,c);
Converter convert;
const PSC_point a = f->halfedge()->vertex()->point();
const PSC_point b = f->halfedge()->next()->vertex()->point();
const PSC_point c = f->halfedge()->next()->next()->vertex()->point();
return convert(PSC_triangle(a,b,c));
}
static bool do_intersect(const Segment& segment, Input f)

View File

@ -9,7 +9,7 @@
namespace CGAL {
template <class Polyhedron, class Kernel>
template <class Polyhedron, class Kernel, class AABBTree_kernel>
class AABB_polyhedral_oracle : public Polyhedron
{
public:
@ -19,15 +19,15 @@ public:
typedef typename Kernel::Point_3 Point_3;
typedef typename Kernel::Segment_3 Segment_3;
typedef AABB_polyhedral_oracle<Polyhedron,Kernel> Self;
typedef AABB_polyhedral_oracle<Polyhedron,Kernel,AABBTree_kernel> Self;
typedef Self Surface_mesher_traits_3;
typedef Point_3 Intersection_point;
typedef Self Surface_3;
// AABB tree
typedef AABB_tree<Kernel,typename Polyhedron::Facet_handle,Polyhedron> Tree;
typedef AABB_tree<AABBTree_kernel,typename Polyhedron::Facet_handle,Polyhedron> Tree;
typedef typename Tree::Point_with_input Point_with_facet_handle;
// typedef CGAL::Cartesian_converter<Kernel,Tree_kernel> Converter;
typedef CGAL::Cartesian_converter<Kernel,AABBTree_kernel> Converter;
Tree *m_pTree;
public:
@ -60,9 +60,9 @@ public:
Object operator()(const Surface_3& surface, const Segment_3& segment) const
{
//Converter convert;
Converter convert;
Point_with_facet_handle pwh;
if(surface.tree()->first_intersection(segment,pwh))
if(surface.tree()->first_intersection(convert(segment),pwh))
return make_object(pwh.first);
else
return Object();
@ -70,9 +70,9 @@ public:
Object operator()(const Surface_3& surface, const Ray_3& ray) const
{
//Converter convert;
Converter convert;
Point_with_facet_handle pwh;
if(surface.tree()->first_intersection(ray,pwh))
if(surface.tree()->first_intersection(convert(ray),pwh))
return make_object(pwh.first);
else
return Object();
@ -80,9 +80,9 @@ public:
Object operator()(const Surface_3& surface, const Line_3& line) const
{
//Converter convert;
Converter convert;
Point_with_facet_handle pwh;
if(surface.tree()->first_intersection(line,pwh))
if(surface.tree()->first_intersection(convert(line),pwh))
return make_object(pwh.first);
else
return Object();