mirror of https://github.com/CGAL/cgal
Modifs of example. Now voronoi2 is a real voronoi diagramm.
This commit is contained in:
parent
a882e94a07
commit
19665940f1
|
|
@ -38,7 +38,7 @@ if ( CGAL_FOUND )
|
||||||
# If you want to visualize a linear cell complex, there are 2 viewers
|
# If you want to visualize a linear cell complex, there are 2 viewers
|
||||||
# based on qt and vtk. Just uncomment the corresponding line
|
# based on qt and vtk. Just uncomment the corresponding line
|
||||||
include("CMakeLCCViewerQt.inc")
|
include("CMakeLCCViewerQt.inc")
|
||||||
# include("CMakeLCCViewerVtk.inc")
|
# include("CMakeLCCViewerVtk.inc")
|
||||||
|
|
||||||
add_executable(linear_cell_complex_3_triangulation
|
add_executable(linear_cell_complex_3_triangulation
|
||||||
linear_cell_complex_3_triangulation.cpp)
|
linear_cell_complex_3_triangulation.cpp)
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
-263.345 -200.31
|
|
||||||
95.2523 -197.508
|
|
||||||
-289.959 187.703
|
|
||||||
-11.2062 207.314
|
|
||||||
184.902 -50.4277
|
|
||||||
-156.886 -343.188
|
|
||||||
84.0461 -324.978
|
|
||||||
-238.131 -54.63
|
|
||||||
-121.867 8.40461
|
-121.867 8.40461
|
||||||
30.8169 130.272
|
30.8169 130.272
|
||||||
163.89 39.2215
|
|
||||||
224.123 -81.2446
|
|
||||||
193.306 138.676
|
193.306 138.676
|
||||||
|
-376.807 164.902
|
||||||
|
-289.959 187.703
|
||||||
|
-11.2062 207.314
|
||||||
|
163.89 39.2215
|
||||||
|
-238.131 -54.63
|
||||||
|
184.902 -50.4277
|
||||||
-329.181 -170.894
|
-329.181 -170.894
|
||||||
-201.711 -438.441
|
224.123 -81.2446
|
||||||
|
-263.345 -200.31
|
||||||
|
95.2523 -197.508
|
||||||
|
-156.886 -343.188
|
||||||
|
84.0461 -324.978
|
||||||
225.524 -385.211
|
225.524 -385.211
|
||||||
-376.807 184.902
|
-201.711 -438.441
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,6 @@ void constrained_delaunay_triangulation(LCC_3 &lcc, Dart_handle d1)
|
||||||
std::cout<<std::endl;
|
std::cout<<std::endl;
|
||||||
|
|
||||||
LCC_3::Vector normal = CGAL::compute_normal_of_cell_2(lcc,d1);
|
LCC_3::Vector normal = CGAL::compute_normal_of_cell_2(lcc,d1);
|
||||||
normal = normal/(CGAL::sqrt(normal*normal));
|
|
||||||
|
|
||||||
P_traits cdt_traits(normal);
|
P_traits cdt_traits(normal);
|
||||||
CDT cdt(cdt_traits);
|
CDT cdt(cdt_traits);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,12 @@
|
||||||
#include <QGLViewer/qglviewer.h>
|
#include <QGLViewer/qglviewer.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <CGAL/Linear_cell_complex.h>
|
#include <CGAL/Linear_cell_complex.h>
|
||||||
|
#include <CGAL/Cartesian.h>
|
||||||
|
#include <CGAL/Cartesian_converter.h>
|
||||||
|
|
||||||
|
typedef CGAL::Cartesian<double> Local_kernel;
|
||||||
|
typedef typename Local_kernel::Point_3 Local_point;
|
||||||
|
typedef typename Local_kernel::Vector_3 Local_vector;
|
||||||
|
|
||||||
template<class LCC, int dim=LCC::ambient_dimension>
|
template<class LCC, int dim=LCC::ambient_dimension>
|
||||||
struct Geom_utils;
|
struct Geom_utils;
|
||||||
|
|
@ -33,72 +39,70 @@ struct Geom_utils;
|
||||||
template<class LCC>
|
template<class LCC>
|
||||||
struct Geom_utils<LCC,3>
|
struct Geom_utils<LCC,3>
|
||||||
{
|
{
|
||||||
typedef typename LCC::Point Point;
|
Local_point get_point(typename LCC::Vertex_attribute_const_handle vh)
|
||||||
typedef typename LCC::Vector Vector;
|
{ return converter(vh->point()); }
|
||||||
|
|
||||||
static Point get_point(typename LCC::Vertex_attribute_const_handle vh)
|
Local_point get_point(typename LCC::Dart_const_handle dh)
|
||||||
{ return vh->point(); }
|
{ return converter(LCC::point(dh)); }
|
||||||
|
|
||||||
static Point get_point(typename LCC::Dart_const_handle dh)
|
Local_vector get_facet_normal(LCC& lcc, typename LCC::Dart_const_handle dh)
|
||||||
{ return LCC::point(dh); }
|
|
||||||
|
|
||||||
static Vector get_facet_normal(LCC& lcc, typename LCC::Dart_const_handle dh)
|
|
||||||
{
|
{
|
||||||
typename LCC::Vector n = CGAL::compute_normal_of_cell_2<LCC>(lcc,dh);
|
Local_vector n = converter(CGAL::compute_normal_of_cell_2<LCC>(lcc,dh));
|
||||||
n = n/(CGAL::sqrt(n*n));
|
n = n/(CGAL::sqrt(n*n));
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector get_vertex_normal(LCC& lcc, typename LCC::Dart_const_handle dh)
|
Local_vector get_vertex_normal(LCC& lcc, typename LCC::Dart_const_handle dh)
|
||||||
{
|
{
|
||||||
Vector n = CGAL::compute_normal_of_cell_0<LCC>(lcc,dh);
|
Local_vector n = converter(CGAL::compute_normal_of_cell_0<LCC>(lcc,dh));
|
||||||
n = n/(CGAL::sqrt(n*n));
|
n = n/(CGAL::sqrt(n*n));
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
protected:
|
||||||
|
CGAL::Cartesian_converter<typename LCC::Traits, Local_kernel> converter;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class LCC>
|
template<class LCC>
|
||||||
struct Geom_utils<LCC,2>
|
struct Geom_utils<LCC,2>
|
||||||
{
|
{
|
||||||
typedef typename LCC::Traits::Point_3 Point;
|
Local_point get_point(typename LCC::Vertex_attribute_const_handle vh)
|
||||||
typedef typename LCC::Traits::Vector_3 Vector;
|
|
||||||
|
|
||||||
static
|
|
||||||
Point get_point(typename LCC::Vertex_attribute_const_handle vh)
|
|
||||||
{
|
{
|
||||||
Point p(vh->point().x(),0,vh->point().y());
|
Local_point p(converter(vh->point().x()),0,converter(vh->point().y()));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Point get_point(typename LCC::Dart_const_handle dh)
|
Local_point get_point(typename LCC::Dart_const_handle dh)
|
||||||
{ return get_point(LCC::vertex_attribute(dh)); }
|
{ return get_point(LCC::vertex_attribute(dh)); }
|
||||||
|
|
||||||
static
|
Local_vector get_facet_normal(LCC&, typename LCC::Dart_const_handle)
|
||||||
Vector get_facet_normal(LCC&, typename LCC::Dart_const_handle)
|
|
||||||
{
|
{
|
||||||
Vector n(0,1,0);
|
Local_vector n(0,1,0);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector get_vertex_normal(LCC&, typename LCC::Dart_const_handle)
|
Local_vector get_vertex_normal(LCC&, typename LCC::Dart_const_handle)
|
||||||
{
|
{
|
||||||
Vector n(0,1,0);
|
Local_vector n(0,1,0);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
protected:
|
||||||
|
CGAL::Cartesian_converter<typename LCC::Traits, Local_kernel> converter;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class LCC>
|
template<class LCC>
|
||||||
CGAL::Bbox_3 bbox(LCC& lcc)
|
CGAL::Bbox_3 bbox(LCC& lcc)
|
||||||
{
|
{
|
||||||
CGAL::Bbox_3 bb;
|
CGAL::Bbox_3 bb;
|
||||||
|
Geom_utils<LCC> geomutils;
|
||||||
|
|
||||||
typename LCC::Vertex_attribute_range::const_iterator
|
typename LCC::Vertex_attribute_range::const_iterator
|
||||||
it=lcc.vertex_attributes().begin(), itend=lcc.vertex_attributes().end();
|
it=lcc.vertex_attributes().begin(), itend=lcc.vertex_attributes().end();
|
||||||
if ( it!=itend )
|
if ( it!=itend )
|
||||||
{
|
{
|
||||||
bb = Geom_utils<LCC>::get_point(it).bbox();
|
bb = geomutils.get_point(it).bbox();
|
||||||
for( ++it; it!=itend; ++it)
|
for( ++it; it!=itend; ++it)
|
||||||
{
|
{
|
||||||
bb = bb + Geom_utils<LCC>::get_point(it).bbox();
|
bb = bb + geomutils.get_point(it).bbox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,8 +113,6 @@ template<class LCC>
|
||||||
class SimpleLCCViewerQt : public QGLViewer
|
class SimpleLCCViewerQt : public QGLViewer
|
||||||
{
|
{
|
||||||
typedef typename LCC::Dart_handle Dart_handle;
|
typedef typename LCC::Dart_handle Dart_handle;
|
||||||
typedef typename Geom_utils<LCC>::Point Point;
|
|
||||||
typedef typename Geom_utils<LCC>::Vector Vector;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -134,7 +136,7 @@ protected :
|
||||||
// If Flat shading: 1 normal per polygon
|
// If Flat shading: 1 normal per polygon
|
||||||
if (flatShading)
|
if (flatShading)
|
||||||
{
|
{
|
||||||
Vector n = Geom_utils<LCC>::get_facet_normal(lcc,ADart);
|
Local_vector n = geomutils.get_facet_normal(lcc,ADart);
|
||||||
::glNormal3d(n.x(),n.y(),n.z());
|
::glNormal3d(n.x(),n.y(),n.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,38 +147,50 @@ protected :
|
||||||
// If Gouraud shading: 1 normal per vertex
|
// If Gouraud shading: 1 normal per vertex
|
||||||
if (!flatShading)
|
if (!flatShading)
|
||||||
{
|
{
|
||||||
Vector n = Geom_utils<LCC>::get_vertex_normal(lcc,ADart);
|
Local_vector n = geomutils.get_vertex_normal(lcc,it);
|
||||||
::glNormal3d(n.x(),n.y(),n.z());
|
::glNormal3d(n.x(),n.y(),n.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
Point p = Geom_utils<LCC>::get_point(it);
|
Local_point p = geomutils.get_point(it);
|
||||||
::glVertex3d(p.x(),p.y(),p.z());
|
::glVertex3d(p.x(),p.y(),p.z());
|
||||||
|
|
||||||
lcc.mark(it, AMark);
|
lcc.mark(it, AMark);
|
||||||
if ( lcc.dimension>=3 && !it->is_free(3) ) lcc.mark(it->beta(3), AMark);
|
if ( lcc.dimension>=3 && !it->is_free(3) ) lcc.mark(it->beta(3), AMark);
|
||||||
}
|
}
|
||||||
|
// close the polygon
|
||||||
|
if (!flatShading)
|
||||||
|
{
|
||||||
|
Local_vector n = geomutils.get_vertex_normal(lcc,ADart);
|
||||||
|
::glNormal3d(n.x(),n.y(),n.z());
|
||||||
|
}
|
||||||
|
|
||||||
|
Local_point p = geomutils.get_point(ADart);
|
||||||
|
::glVertex3d(p.x(),p.y(),p.z());
|
||||||
|
|
||||||
::glEnd();
|
::glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draw all the edge of the facet given by ADart
|
/// Draw all the edge of the facet given by ADart
|
||||||
void drawEdges(Dart_handle ADart)
|
void drawEdges(Dart_handle ADart)
|
||||||
{
|
{
|
||||||
|
glDepthRange (0.0, 0.9);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glColor3f(.2,.2,.6);
|
::glColor3f(.2,.2,.6);
|
||||||
for (typename LCC::template Dart_of_orbit_range<1>::iterator
|
for (typename LCC::template Dart_of_orbit_range<1>::iterator
|
||||||
it=lcc.template darts_of_orbit<1>(ADart).begin();
|
it=lcc.template darts_of_orbit<1>(ADart).begin();
|
||||||
it.cont(); ++it)
|
it.cont(); ++it)
|
||||||
{
|
{
|
||||||
Point p = Geom_utils<LCC>::get_point(it);
|
Local_point p = geomutils.get_point(it);
|
||||||
Dart_handle d2 = it->opposite();
|
Dart_handle d2 = it->other_extremity();
|
||||||
if ( d2!=NULL )
|
if ( d2!=NULL )
|
||||||
{
|
{
|
||||||
Point p2 = Geom_utils<LCC>::get_point(d2);
|
Local_point p2 = geomutils.get_point(d2);
|
||||||
glVertex3f( p.x(),p.y(),p.z());
|
glVertex3f( p.x(),p.y(),p.z());
|
||||||
glVertex3f( p2.x(),p2.y(),p2.z());
|
glVertex3f( p2.x(),p2.y(),p2.z());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
|
glDepthRange (0.1, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void draw()
|
virtual void draw()
|
||||||
|
|
@ -199,12 +213,14 @@ protected :
|
||||||
{
|
{
|
||||||
if ( !lcc.is_marked(it, vertextreated) )
|
if ( !lcc.is_marked(it, vertextreated) )
|
||||||
{
|
{
|
||||||
Point p = Geom_utils<LCC>::get_point(it);
|
Local_point p = geomutils.get_point(it);
|
||||||
|
|
||||||
|
glDepthRange (0.0, 0.9);
|
||||||
glBegin(GL_POINTS);
|
glBegin(GL_POINTS);
|
||||||
glColor3f(.6,.2,.8);
|
::glColor3f(.6,.2,.8);
|
||||||
glVertex3f(p.x(),p.y(),p.z());
|
glVertex3f(p.x(),p.y(),p.z());
|
||||||
glEnd();
|
glEnd();
|
||||||
|
glDepthRange (0.1, 1.0);
|
||||||
|
|
||||||
CGAL::mark_cell<LCC, 0>(lcc, it, vertextreated);
|
CGAL::mark_cell<LCC, 0>(lcc, it, vertextreated);
|
||||||
}
|
}
|
||||||
|
|
@ -237,10 +253,10 @@ protected :
|
||||||
setKeyDescription(Qt::Key_V, "Toggles vertices display");
|
setKeyDescription(Qt::Key_V, "Toggles vertices display");
|
||||||
|
|
||||||
// Light default parameters
|
// Light default parameters
|
||||||
::glLineWidth(1.4f);
|
::glLineWidth(2.4f);
|
||||||
::glPointSize(4.f);
|
::glPointSize(7.f);
|
||||||
::glEnable(GL_POLYGON_OFFSET_FILL);
|
// ::glEnable(GL_POLYGON_OFFSET_FILL);
|
||||||
::glPolygonOffset(1.0f,1.0f);
|
// ::glPolygonOffset(1.f,1.f);
|
||||||
::glClearColor(1.0f,1.0f,1.0f,0.0f);
|
::glClearColor(1.0f,1.0f,1.0f,0.0f);
|
||||||
::glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
|
::glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
|
||||||
|
|
||||||
|
|
@ -372,6 +388,7 @@ private:
|
||||||
bool flatShading;
|
bool flatShading;
|
||||||
bool edges;
|
bool edges;
|
||||||
bool vertices;
|
bool vertices;
|
||||||
|
Geom_utils<LCC> geomutils;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class LCC>
|
template<class LCC>
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,12 @@
|
||||||
#include <vtkPolygon.h>
|
#include <vtkPolygon.h>
|
||||||
#include <vtkCellArray.h>
|
#include <vtkCellArray.h>
|
||||||
#include <CGAL/Linear_cell_complex.h>
|
#include <CGAL/Linear_cell_complex.h>
|
||||||
|
#include <CGAL/Cartesian.h>
|
||||||
|
#include <CGAL/Cartesian_converter.h>
|
||||||
|
|
||||||
|
typedef CGAL::Cartesian<double> Local_kernel;
|
||||||
|
typedef typename Local_kernel::Point_3 Local_point;
|
||||||
|
typedef typename Local_kernel::Vector_3 Local_vector;
|
||||||
|
|
||||||
template<class LCC, int dim=LCC::ambient_dimension>
|
template<class LCC, int dim=LCC::ambient_dimension>
|
||||||
struct Geom_utils;
|
struct Geom_utils;
|
||||||
|
|
@ -42,61 +48,56 @@ struct Geom_utils;
|
||||||
template<class LCC>
|
template<class LCC>
|
||||||
struct Geom_utils<LCC,3>
|
struct Geom_utils<LCC,3>
|
||||||
{
|
{
|
||||||
typedef typename LCC::Point Point;
|
Local_point get_point(typename LCC::Vertex_attribute_const_handle vh)
|
||||||
typedef typename LCC::Vector Vector;
|
{ return converter(vh->point()); }
|
||||||
|
|
||||||
static Point get_point(typename LCC::Vertex_attribute_const_handle vh)
|
Local_point get_point(typename LCC::Dart_const_handle dh)
|
||||||
{ return vh->point(); }
|
{ return converter(LCC::point(dh)); }
|
||||||
|
|
||||||
static Point get_point(typename LCC::Dart_const_handle dh)
|
Local_vector get_facet_normal(LCC& lcc, typename LCC::Dart_const_handle dh)
|
||||||
{ return LCC::point(dh); }
|
|
||||||
|
|
||||||
static Vector get_facet_normal(LCC& lcc, typename LCC::Dart_const_handle dh)
|
|
||||||
{
|
{
|
||||||
typename LCC::Vector n = CGAL::compute_normal_of_cell_2<LCC>(lcc,dh);
|
Local_vector n = converter(CGAL::compute_normal_of_cell_2<LCC>(lcc,dh));
|
||||||
n = n/(CGAL::sqrt(n*n));
|
n = n/(CGAL::sqrt(n*n));
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector get_vertex_normal(LCC& lcc, typename LCC::Dart_const_handle dh)
|
Local_vector get_vertex_normal(LCC& lcc, typename LCC::Dart_const_handle dh)
|
||||||
{
|
{
|
||||||
Vector n = CGAL::compute_normal_of_cell_0<LCC>(lcc,dh);
|
Local_vector n = converter(CGAL::compute_normal_of_cell_0<LCC>(lcc,dh));
|
||||||
n = n/(CGAL::sqrt(n*n));
|
n = n/(CGAL::sqrt(n*n));
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
protected:
|
||||||
|
CGAL::Cartesian_converter<typename LCC::Traits, Local_kernel> converter;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class LCC>
|
template<class LCC>
|
||||||
struct Geom_utils<LCC,2>
|
struct Geom_utils<LCC,2>
|
||||||
{
|
{
|
||||||
typedef typename LCC::Traits::Point_3 Point;
|
Local_point get_point(typename LCC::Vertex_attribute_const_handle vh)
|
||||||
typedef typename LCC::Traits::Vector_3 Vector;
|
|
||||||
|
|
||||||
static
|
|
||||||
Point get_point(typename LCC::Vertex_attribute_const_handle vh)
|
|
||||||
{
|
{
|
||||||
Point p(vh->point().x(),vh->point().y(),0);
|
Local_point p(converter(vh->point().x()),0,converter(vh->point().y()));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Point get_point(typename LCC::Dart_const_handle dh)
|
Local_point get_point(typename LCC::Dart_const_handle dh)
|
||||||
{ return get_point(LCC::vertex_attribute(dh)); }
|
{ return get_point(LCC::vertex_attribute(dh)); }
|
||||||
|
|
||||||
static
|
Local_vector get_facet_normal(LCC&, typename LCC::Dart_const_handle)
|
||||||
Vector get_facet_normal(LCC&, typename LCC::Dart_const_handle)
|
|
||||||
{
|
{
|
||||||
Vector n(0,0,1);
|
Local_vector n(0,1,0);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector get_vertex_normal(LCC&, typename LCC::Dart_const_handle)
|
Local_vector get_vertex_normal(LCC&, typename LCC::Dart_const_handle)
|
||||||
{
|
{
|
||||||
Vector n(0,0,1);
|
Local_vector n(0,1,0);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
protected:
|
||||||
|
CGAL::Cartesian_converter<typename LCC::Traits, Local_kernel> converter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SimpleViewVtk : public QMainWindow
|
class SimpleViewVtk : public QMainWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -140,8 +141,7 @@ template<class LCC>
|
||||||
class SimpleLCCViewerVtk : public SimpleViewVtk
|
class SimpleLCCViewerVtk : public SimpleViewVtk
|
||||||
{
|
{
|
||||||
typedef typename LCC::Dart_handle Dart_handle;
|
typedef typename LCC::Dart_handle Dart_handle;
|
||||||
typedef typename Geom_utils<LCC>::Point Point;
|
Geom_utils<LCC> geomutils;
|
||||||
typedef typename Geom_utils<LCC>::Vector Vector;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SimpleLCCViewerVtk(LCC& lcc) : SimpleViewVtk()
|
SimpleLCCViewerVtk(LCC& lcc) : SimpleViewVtk()
|
||||||
|
|
@ -179,7 +179,7 @@ public:
|
||||||
it2=lcc.template darts_of_orbit<1>(it).begin();
|
it2=lcc.template darts_of_orbit<1>(it).begin();
|
||||||
it2.cont(); ++it2)
|
it2.cont(); ++it2)
|
||||||
{
|
{
|
||||||
Point p = Geom_utils<LCC>::get_point(it2);
|
Local_point p = geomutils.get_point(it2);
|
||||||
vtkIdType id=points->InsertNextPoint(p.x(),p.y(),p.z());
|
vtkIdType id=points->InsertNextPoint(p.x(),p.y(),p.z());
|
||||||
++nbpoints;
|
++nbpoints;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,16 +43,17 @@ typedef CGAL::Delaunay_triangulation_2<LCC_2::Traits> Triangulation;
|
||||||
// Function used to display the voronoi diagram.
|
// Function used to display the voronoi diagram.
|
||||||
void display_voronoi(LCC_2& alcc, Dart_handle adart)
|
void display_voronoi(LCC_2& alcc, Dart_handle adart)
|
||||||
{
|
{
|
||||||
// We remove all the faces containing one dart of the infinite faces
|
// We remove the infinite face plus all the faces adjacent to it.
|
||||||
|
// Indeed, we cannot view these faces since they do not have
|
||||||
|
// a "correct geometry".
|
||||||
std::stack<Dart_handle> toremove;
|
std::stack<Dart_handle> toremove;
|
||||||
int mark_toremove=alcc.get_new_mark();
|
int mark_toremove=alcc.get_new_mark();
|
||||||
|
|
||||||
// We cannot view the infinite face since it does not have
|
// adart belongs to the infinite face.
|
||||||
// a correct geometry. For that we have to remove the infinite face.
|
|
||||||
toremove.push(adart);
|
toremove.push(adart);
|
||||||
CGAL::mark_cell<LCC_2,2>(alcc, adart, mark_toremove);
|
CGAL::mark_cell<LCC_2,2>(alcc, adart, mark_toremove);
|
||||||
|
|
||||||
// Plus all the faces sharing an edge with it.
|
// Now we get all the faces adjacent to the infinite face.
|
||||||
for (LCC_2::Dart_of_cell_range<2>::iterator
|
for (LCC_2::Dart_of_cell_range<2>::iterator
|
||||||
it=alcc.darts_of_cell<2>(adart).begin(),
|
it=alcc.darts_of_cell<2>(adart).begin(),
|
||||||
itend=alcc.darts_of_cell<2>(adart).end(); it!=itend; ++it)
|
itend=alcc.darts_of_cell<2>(adart).end(); it!=itend; ++it)
|
||||||
|
|
@ -109,23 +110,16 @@ void set_geometry_of_dual(LCC& alcc, TR& tr,
|
||||||
std::map<typename TR::Face_handle,
|
std::map<typename TR::Face_handle,
|
||||||
typename LCC::Dart_handle>& assoc)
|
typename LCC::Dart_handle>& assoc)
|
||||||
{
|
{
|
||||||
/* std::cout<<"Avant ";
|
|
||||||
for (typename LCC::template One_dart_per_cell_range<0>::
|
|
||||||
iterator it=alcc.template one_dart_per_cell<0>().begin(),
|
|
||||||
itend=alcc.template one_dart_per_cell<0>().end();
|
|
||||||
it!=itend; ++it)
|
|
||||||
{
|
|
||||||
std::cout << LCC::point(it) << "; ";
|
|
||||||
}
|
|
||||||
std::cout<<std::endl;*/
|
|
||||||
|
|
||||||
for ( typename std::map<typename TR::Face_handle, typename LCC::Dart_handle>
|
for ( typename std::map<typename TR::Face_handle, typename LCC::Dart_handle>
|
||||||
::iterator it=assoc.begin(), itend=assoc.end(); it!=itend; ++it)
|
::iterator it=assoc.begin(), itend=assoc.end(); it!=itend; ++it)
|
||||||
{
|
{
|
||||||
LCC::point(it->second)=tr.circumcenter(it->first);
|
if ( !tr.is_infinite(it->first) )
|
||||||
std::cout<<LCC::point(it->second)<<" ";
|
alcc.set_vertex_attribute
|
||||||
|
(it->second,alcc.create_vertex_attribute(tr.circumcenter(it->first)));
|
||||||
|
else
|
||||||
|
alcc.set_vertex_attribute
|
||||||
|
(it->second,alcc.create_vertex_attribute());
|
||||||
}
|
}
|
||||||
std::cout<<std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int narg, char** argv)
|
int main(int narg, char** argv)
|
||||||
|
|
@ -191,7 +185,7 @@ int main(int narg, char** argv)
|
||||||
(lcc, dual_lcc, face_to_dart);
|
(lcc, dual_lcc, face_to_dart);
|
||||||
set_geometry_of_dual<LCC_2,Triangulation>(dual_lcc, T, face_to_dart);
|
set_geometry_of_dual<LCC_2,Triangulation>(dual_lcc, T, face_to_dart);
|
||||||
|
|
||||||
// 4) Display the dual_lcc characteristics.
|
// 5) Display the dual_lcc characteristics.
|
||||||
std::cout<<"Voronoi subdvision :"<<std::endl<<" ";
|
std::cout<<"Voronoi subdvision :"<<std::endl<<" ";
|
||||||
dual_lcc.display_characteristics(std::cout) << ", valid="
|
dual_lcc.display_characteristics(std::cout) << ", valid="
|
||||||
<< dual_lcc.is_valid()
|
<< dual_lcc.is_valid()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue