First version of insert_if_in_star that is too restrictive

We need to check that star_center is not part of the conflict zone.
This commit is contained in:
Clement Jamin 2014-07-30 18:07:03 +02:00
parent 78428ac253
commit b916d18319
3 changed files with 158 additions and 4 deletions

View File

@ -265,6 +265,32 @@ public:
Vertex_handle insert_outside_affine_hull(const Weighted_point &);
Vertex_handle insert_in_conflicting_cell(const Weighted_point &, const Full_cell_handle);
Vertex_handle insert_if_in_star(const Weighted_point &,
const Vertex_handle,
const Locate_type,
const Face &,
const Facet &,
const Full_cell_handle);
Vertex_handle insert_if_in_star(
const Weighted_point & p, const Vertex_handle star_center,
const Full_cell_handle start = Full_cell_handle())
{
Locate_type lt;
Face f(maximal_dimension());
Facet ft;
Full_cell_handle s = locate(p, lt, f, ft, start);
return insert_if_in_star(p, star_center, lt, f, ft, s);
}
Vertex_handle insert_if_in_star(
const Weighted_point & p, const Vertex_handle star_center,
const Vertex_handle hint)
{
CGAL_assertion( Vertex_handle() != hint );
return insert_if_in_star(p, hint->full_cell());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - GATHERING CONFLICTING SIMPLICES
@ -780,6 +806,48 @@ Regular_triangulation<RTTraits, TDS>
return insert_in_hole(p, cs.begin(), cs.end(), ft);
}
template< typename RTTraits, typename TDS >
typename Regular_triangulation<RTTraits, TDS>::Vertex_handle
Regular_triangulation<RTTraits, TDS>
::insert_if_in_star(const Weighted_point & p,
const Vertex_handle star_center,
const Locate_type lt, const Face & f, const Facet & ft,
const Full_cell_handle s)
{
switch( lt )
{
case Base::OUTSIDE_AFFINE_HULL:
return insert_outside_affine_hull(p);
break;
case Base::ON_VERTEX:
{
Vertex_handle v = s->vertex(f.index(0));
v->set_point(p);
return v;
break;
}
default:
if (s->has_vertex(star_center))
{
if( 1 == current_dimension() )
{
if( Base::OUTSIDE_CONVEX_HULL == lt )
{
return insert_outside_convex_hull_1(p, s);
}
Vertex_handle v = tds().insert_in_full_cell(s);
v->set_point(p);
return v;
}
else
return insert_in_conflicting_cell(p, s);
}
break;
}
return Vertex_handle();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GATHERING CONFLICTING SIMPLICES
// NOT DOCUMENTED

View File

@ -1,7 +1,6 @@
# Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application.
project( Triangulation_test )
cmake_minimum_required(VERSION 2.6.2)
@ -27,19 +26,18 @@ if ( CGAL_FOUND )
include_directories (BEFORE "../../include")
include_directories (BEFORE "include")
create_single_source_cgal_program( "test_triangulation.cpp" )
create_single_source_cgal_program( "test_delaunay.cpp" )
create_single_source_cgal_program( "test_regular.cpp" )
create_single_source_cgal_program( "test_tds.cpp" )
create_single_source_cgal_program( "test_insert_if_in_star.cpp" )
create_single_source_cgal_program( "test_torture.cpp" )
create_single_source_cgal_program( "test_triangulation.cpp" )
else()
message(STATUS "NOTICE: Some of the executables in this directory need Eigen 3.1 (or greater) and will not be compiled.")
endif()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()

View File

@ -0,0 +1,88 @@
#include <CGAL/Epick_d.h>
#include <CGAL/point_generators_d.h>
#include <CGAL/Regular_triangulation.h>
#include <CGAL/Regular_triangulation_euclidean_traits.h>
#include <CGAL/IO/Triangulation_off_ostream.h>
#include <CGAL/algorithm.h>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>
#include <algorithm>
using namespace std;
template<typename RTri>
void test(const int d, const string & type, const int N)
{
typedef typename RTri::Vertex_handle Vertex_handle;
typedef typename RTri::Point Point;
typedef typename RTri::Bare_point Bare_point;
typedef CGAL::Random_points_in_cube_d<Bare_point> Random_points_iterator;
RTri rt(d);
RTri rt_star_only(d);
cerr << "\nBuilding Regular triangulation of (" << type << d
<< ") dimension with " << N << " points\n";
assert(rt.empty());
assert(rt_star_only.empty());
srand(10);
// Insert first point (0, 0...)
vector<double> coords(d);
for( int j = 0; j < d; ++j )
coords[j] = 0;
Point p = Point(
Bare_point(d, coords.begin(), coords.end()),
static_cast<double>(rand() % 10000)/100000);
rt.insert(p);
Vertex_handle first_vertex = rt_star_only.insert(p);
// Insert the other points
for( int i = 1 ; i < N ; ++i )
{
for( int j = 0; j < d; ++j )
coords[j] = 10.*(rand() % RAND_MAX)/RAND_MAX - 5.;
p = Point(
Bare_point(d, coords.begin(), coords.end()),
static_cast<double>(rand() % 10000)/100000);
rt.insert(p);
rt_star_only.insert_if_in_star(p, first_vertex);
}
cerr << "\nChecking topology and geometry..."
<< (rt.is_valid(true) ? "OK.\n" : "Error.\n");
cerr << "\nThe triangulation has current dimension " << rt.current_dimension()
<< " and " << rt.number_of_full_cells() << " full cells\n";
// Export
std::ofstream off_stream_all("data/test_insert_all.off");
CGAL::export_triangulation_to_off(off_stream_all, rt);
std::ofstream off_stream_star_only("data/test_insert_if_in_star.off");
CGAL::export_triangulation_to_off(off_stream_star_only, rt_star_only);
}
template< int D >
void go(const int N)
{
//typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> FK;
typedef CGAL::Epick_d<CGAL::Dimension_tag<D> > FK;
typedef CGAL::Regular_triangulation_euclidean_traits<FK> Traits;
typedef CGAL::Regular_triangulation<Traits> Triangulation;
//test<Triangulation>(D, "dynamic", N);
test<Triangulation>(D, "static", N);
}
int main(int argc, char **argv)
{
go<2>(100);
return 0;
}