mirror of https://github.com/CGAL/cgal
Add the possibility to remove the far points
The far points are added by the parallel version to reduce the contention on the infinite vertex
This commit is contained in:
parent
0cb9945e58
commit
078e89f55f
|
|
@ -508,7 +508,7 @@ initialize()
|
|||
|
||||
# ifndef CGAL_PARALLEL_MESH_3_DO_NOT_ADD_OUTSIDE_POINTS_ON_A_FAR_SPHERE
|
||||
|
||||
if (r_c3t3_.number_of_facets() == 0)
|
||||
if (r_c3t3_.number_of_far_points() == 0 && r_c3t3_.number_of_facets() == 0)
|
||||
{
|
||||
const Bbox_3 &bbox = estimated_bbox;
|
||||
|
||||
|
|
@ -531,7 +531,7 @@ initialize()
|
|||
tbb::task_scheduler_init::default_num_threads()
|
||||
* Concurrent_mesher_config::get().num_pseudo_infinite_vertices_per_core);
|
||||
for (int i = 0 ; i < NUM_PSEUDO_INFINITE_VERTICES ; ++i, ++random_point)
|
||||
r_c3t3_.triangulation().insert(*random_point + center);
|
||||
r_c3t3_.add_far_point(*random_point + center);
|
||||
|
||||
# ifdef CGAL_CONCURRENT_MESH_3_VERBOSE
|
||||
std::cerr << "done." << std::endl;
|
||||
|
|
@ -555,7 +555,7 @@ initialize()
|
|||
#endif // CGAL_LINKED_WITH_TBB
|
||||
{
|
||||
#ifdef CGAL_SEQUENTIAL_MESH_3_ADD_OUTSIDE_POINTS_ON_A_FAR_SPHERE
|
||||
if (r_c3t3_.number_of_facets() == 0)
|
||||
if (r_c3t3_.number_of_far_points() == 0 && r_c3t3_.number_of_facets() == 0)
|
||||
{
|
||||
/*std::cerr << "A little bit of refinement... ";
|
||||
|
||||
|
|
@ -590,7 +590,7 @@ initialize()
|
|||
Random_points_on_sphere_3<Point> random_point(radius);
|
||||
const int NUM_PSEUDO_INFINITE_VERTICES = 12*2;
|
||||
for (int i = 0 ; i < NUM_PSEUDO_INFINITE_VERTICES ; ++i, ++random_point)
|
||||
r_c3t3_.triangulation().insert(*random_point + center);
|
||||
r_c3t3_.add_far_point(*random_point + center);
|
||||
# ifdef CGAL_MESH_3_VERBOSE
|
||||
std::cerr << "done." << std::endl;
|
||||
# endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2009-2010 INRIA Sophia-Antipolis (France).
|
||||
// Copyright (c) 2009-2014 INRIA Sophia-Antipolis (France).
|
||||
// Copyright (c) 2010-2013 GeometryFactory Sarl (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Stephane Tayeb
|
||||
// Author(s) : Stephane Tayeb, Clement Jamin
|
||||
//
|
||||
//******************************************************************************
|
||||
// File Description :
|
||||
|
|
@ -60,7 +60,8 @@ private:
|
|||
|
||||
public:
|
||||
typedef typename Base::size_type size_type;
|
||||
|
||||
|
||||
typedef typename Tr::Point Point;
|
||||
typedef typename Base::Edge Edge;
|
||||
typedef typename Base::Vertex_handle Vertex_handle;
|
||||
typedef CornerIndex Corner_index;
|
||||
|
|
@ -83,6 +84,8 @@ private:
|
|||
|
||||
// Type to store the corners
|
||||
typedef std::map<Vertex_handle,Corner_index> Corner_map;
|
||||
// Type to store far vertices
|
||||
typedef std::vector<Vertex_handle> Far_vertices_vec;
|
||||
|
||||
public:
|
||||
/**
|
||||
|
|
@ -120,6 +123,7 @@ public:
|
|||
Base::swap(rhs);
|
||||
edges_.swap(rhs.edges_);
|
||||
corners_.swap(rhs.corners_);
|
||||
far_vertices_.swap(rhs.far_vertices_);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -136,6 +140,9 @@ public:
|
|||
using Base::is_in_complex;
|
||||
using Base::add_to_complex;
|
||||
using Base::remove_from_complex;
|
||||
using Base::triangulation;
|
||||
using Base::set_surface_patch_index;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -193,6 +200,62 @@ public:
|
|||
v->set_dimension(-1);
|
||||
}
|
||||
|
||||
std::size_t number_of_far_points() const
|
||||
{
|
||||
return far_vertices_.size();
|
||||
}
|
||||
|
||||
void add_far_point(const Point &p)
|
||||
{
|
||||
far_vertices_.push_back(triangulation().insert(p));
|
||||
}
|
||||
|
||||
void add_far_point(Vertex_handle vh)
|
||||
{
|
||||
far_vertices_.push_back(vh);
|
||||
}
|
||||
|
||||
void remove_far_points()
|
||||
{
|
||||
Triangulation &tr = triangulation();
|
||||
//triangulation().remove(far_vertices_.begin(), far_vertices_.end());
|
||||
Far_vertices_vec::const_iterator it = far_vertices_.begin();
|
||||
Far_vertices_vec::const_iterator it_end = far_vertices_.end();
|
||||
for ( ; it != it_end ; ++it)
|
||||
{
|
||||
std::vector<Cell_handle> new_cells;
|
||||
new_cells.reserve(32);
|
||||
tr.remove_and_give_new_cells(*it, std::back_inserter(new_cells));
|
||||
|
||||
std::vector<Cell_handle>::iterator nc_it = new_cells.begin();
|
||||
std::vector<Cell_handle>::iterator nc_it_end = new_cells.end();
|
||||
for ( ; nc_it != nc_it_end ; ++nc_it)
|
||||
{
|
||||
Cell_handle c = *nc_it;
|
||||
for (int i = 0 ; i < 4 ; ++i)
|
||||
{
|
||||
Facet mirror_facet = tr.mirror_facet(std::make_pair(c, i));
|
||||
if (is_in_complex(mirror_facet))
|
||||
{
|
||||
set_surface_patch_index(c, i,
|
||||
surface_patch_index(mirror_facet));
|
||||
}
|
||||
}
|
||||
/*int i_inf;
|
||||
if (c->has_vertex(tr.infinite_vertex(), i_inf))
|
||||
{
|
||||
Facet mirror_facet = tr.mirror_facet(std::make_pair(c, i_inf));
|
||||
if (is_in_complex(mirror_facet))
|
||||
{
|
||||
set_surface_patch_index(c, i_inf,
|
||||
surface_patch_index(mirror_facet));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
far_vertices_.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of edges of c3t3
|
||||
*/
|
||||
|
|
@ -479,6 +542,7 @@ private:
|
|||
private:
|
||||
Edge_map edges_;
|
||||
Corner_map corners_;
|
||||
Far_vertices_vec far_vertices_;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -513,6 +577,20 @@ Mesh_complex_3_in_triangulation_3(const Self& rhs)
|
|||
this->triangulation().is_vertex(it->first->point(), new_v);
|
||||
this->add_to_complex(new_v, it->second);
|
||||
}
|
||||
|
||||
// Parse vertices to identify far vertices
|
||||
if (rhs.far_vertices_.size() > 0)
|
||||
{
|
||||
Triangulation &tr = triangulation();
|
||||
typename Tr::Finite_vertices_iterator vit = tr.finite_vertices_begin();
|
||||
for(typename Tr::Finite_vertices_iterator end = tr.finite_vertices_end();
|
||||
vit != end ; ++vit)
|
||||
{
|
||||
if (vit->in_dimension() == -1)
|
||||
far_vertices_.push_back(vit);
|
||||
}
|
||||
CGAL_assertion(far_vertices_.size() == rhs.far_vertices_.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,22 @@ namespace CGAL {
|
|||
Vertex_handle new_vertex = r_c3t3_.triangulation().insert(point);
|
||||
r_c3t3_.set_index(new_vertex, index);
|
||||
r_c3t3_.set_dimension(new_vertex, dimension);
|
||||
|
||||
#if defined(CGAL_LINKED_WITH_TBB)\
|
||||
&& !defined(CGAL_PARALLEL_MESH_3_DO_NOT_ADD_OUTSIDE_POINTS_ON_A_FAR_SPHERE)
|
||||
if (boost::is_convertible<C3T3::Concurrency_tag, CGAL::Parallel_tag>::value)
|
||||
{
|
||||
if (dimension == -1)
|
||||
r_c3t3_.add_far_point(new_vertex);
|
||||
}
|
||||
#endif
|
||||
#ifdef CGAL_SEQUENTIAL_MESH_3_ADD_OUTSIDE_POINTS_ON_A_FAR_SPHERE
|
||||
if (boost::is_convertible<C3T3::Concurrency_tag, CGAL::Sequential_tag>::value)
|
||||
{
|
||||
if (dimension == -1)
|
||||
r_c3t3_.add_far_point(new_vertex);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ struct Mesh_new_facet_criteria {
|
|||
|
||||
#include <CGAL/Implicit_mesh_domain_3.h>
|
||||
#include <CGAL/make_mesh_3.h>
|
||||
#include <CGAL/remove_far_points_in_mesh_3.h>
|
||||
|
||||
// Domain
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
|
|
@ -128,6 +129,7 @@ void test()
|
|||
// Mesh generation
|
||||
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, no_exude(), no_perturb());
|
||||
CGAL::refine_mesh_3<C3t3>(c3t3, domain, new_criteria, no_exude(), no_perturb());
|
||||
CGAL::remove_far_points_in_mesh_3(c3t3);
|
||||
|
||||
std::cout << "Number of vertices: "
|
||||
<< c3t3.triangulation().number_of_vertices() << "\n"
|
||||
|
|
|
|||
|
|
@ -85,9 +85,11 @@ struct Implicit_tester : public Tester<K>
|
|||
CGAL::refine_mesh_3(c3t3, domain, criteria,
|
||||
CGAL::parameters::no_exude(),
|
||||
CGAL::parameters::no_perturb());
|
||||
|
||||
|
||||
CGAL::remove_far_points_in_mesh_3(c3t3);
|
||||
|
||||
// Verify
|
||||
this->verify(c3t3,domain,criteria,Bissection_tag(),50,58,80,90);
|
||||
this->verify(c3t3,domain,criteria,Bissection_tag(), 50, 58, 70, 90);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -75,12 +75,14 @@ struct Polyhedron_tester : public Tester<K>
|
|||
CGAL::refine_mesh_3(c3t3, domain, criteria,
|
||||
CGAL::parameters::no_exude(),
|
||||
CGAL::parameters::no_perturb());
|
||||
|
||||
CGAL::remove_far_points_in_mesh_3(c3t3);
|
||||
|
||||
// Verify
|
||||
double vol = 0.479171765761454;
|
||||
this->verify_c3t3_volume(c3t3, vol*0.95, vol*1.05);
|
||||
this->verify(c3t3,domain,criteria,Polyhedral_tag(),
|
||||
119, 121, 200, 204, 350, 360); }
|
||||
110, 140, 190, 230, 350, 420); }
|
||||
};
|
||||
|
||||
int main()
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ struct Polyhedron_with_features_tester : public Tester<K>
|
|||
CGAL::parameters::no_exude(),
|
||||
CGAL::parameters::no_perturb());
|
||||
|
||||
CGAL::remove_far_points_in_mesh_3(c3t3);
|
||||
|
||||
// Verify
|
||||
this->verify(c3t3,domain,criteria,
|
||||
Polyhedral_tag()); //, 1099, 1099, 1158, 1158, 4902, 4902);
|
||||
|
|
|
|||
|
|
@ -58,10 +58,11 @@ struct Polyhedron_tester : public Tester<K>
|
|||
cell_size = cs);
|
||||
// Mesh generation
|
||||
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);
|
||||
|
||||
|
||||
CGAL::remove_far_points_in_mesh_3(c3t3);
|
||||
|
||||
double vol = 1/6.;
|
||||
this->verify_c3t3_volume(c3t3, vol*0.95, vol*1.05);
|
||||
|
||||
this->verify_c3t3(c3t3,domain,Polyhedral_tag(),
|
||||
55, 65, 110, 125, 85, 120);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ struct Tester
|
|||
const double reference_value) const
|
||||
{
|
||||
double hdist = compute_hausdorff_distance(c3t3, domain, Polyhedral_tag());
|
||||
assert(hdist <= reference_value*1.01);
|
||||
assert(hdist <= reference_value*1.05);
|
||||
}
|
||||
|
||||
template<typename C3t3, typename MeshDomain>
|
||||
|
|
|
|||
|
|
@ -660,6 +660,18 @@ namespace CGAL {
|
|||
return n - number_of_vertices();
|
||||
}
|
||||
|
||||
|
||||
template <class OutputItCells>
|
||||
void remove_and_give_new_cells(Vertex_handle v, OutputItCells cit)
|
||||
{
|
||||
Self tmp;
|
||||
Vertex_remover<Self> remover (tmp);
|
||||
Tr_Base::remove_and_give_new_cells(v, remover, cit);
|
||||
|
||||
CGAL_triangulation_expensive_postcondition(is_valid());
|
||||
}
|
||||
|
||||
|
||||
// DISPLACEMENT
|
||||
Vertex_handle move_point(Vertex_handle v, const Weighted_point & p);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue