mirror of https://github.com/CGAL/cgal
- Add a new TCellBase model Triangulation_cell_base_with_circumcenter_3,
which stores the circumcenter. - Delaunay.dual() now calls the .circumcenter() function of the cell to retrieve it. - It implies a new requirement on the TCellBase, for the Delaunay::dual() case, hence the default model T_cell_base_3 provides a new function (and the concept is updated).
This commit is contained in:
parent
090cd4e34e
commit
cf872de855
|
|
@ -33,6 +33,7 @@ int main()
|
|||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/Delaunay_triangulation_3.h>
|
||||
#include <CGAL/Triangulation_cell_base_with_circumcenter_3.h>
|
||||
|
||||
#include <CGAL/IO/Triangulation_geomview_ostream_3.h>
|
||||
|
||||
|
|
@ -42,7 +43,11 @@ int main()
|
|||
// demo, not only predicates
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
|
||||
|
||||
typedef CGAL::Delaunay_triangulation_3<K> Triangulation;
|
||||
typedef CGAL::Triangulation_vertex_base_3<K> Vb;
|
||||
typedef CGAL::Triangulation_cell_base_with_circumcenter_3<K> Cb;
|
||||
typedef CGAL::Triangulation_data_structure_3<Vb, Cb> TDS;
|
||||
typedef CGAL::Delaunay_triangulation_3<K, TDS> Triangulation;
|
||||
// typedef CGAL::Delaunay_triangulation_3<K> Triangulation;
|
||||
|
||||
typedef Triangulation::Point Point;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ include $(CGAL_MAKEFILE)
|
|||
#---------------------------------------------------------------------#
|
||||
|
||||
CXXFLAGS = \
|
||||
-I$(HOME)/CGAL/trunk/Kernel_23/include \
|
||||
-I../../include \
|
||||
$(TESTSUITE_CXXFLAGS) \
|
||||
$(EXTRA_FLAGS) \
|
||||
|
|
|
|||
|
|
@ -15,17 +15,26 @@
|
|||
|
||||
\ccDefinition
|
||||
|
||||
The cell base required by the geometric triangulations does not store any
|
||||
The cell base required by the basic triangulation does not need to store any
|
||||
geometric information, so only the requirements of the triangulation data
|
||||
structure apply. However, we provide this concept for symmetry with the
|
||||
vertex case.
|
||||
structure apply.
|
||||
|
||||
However, for the Delaunay triangulation, the ability to store the circumcenter
|
||||
is provided (for optimization reasons), hence an additional requirement only
|
||||
in this case, and only when the dual functions are called.
|
||||
|
||||
\ccRefines \ccc{TriangulationDSCellBase_3}
|
||||
|
||||
\ccMethod{const DelaunayTriangulationTraits_3::Point_3& circumcenter(
|
||||
const DelaunayTriangulationTraits_3> = DelaunayTriangulationTraits_3()) const;}
|
||||
{Returns the circumcenter.}
|
||||
|
||||
|
||||
\ccHasModels
|
||||
|
||||
\ccc{CGAL::Triangulation_cell_base_3}\\
|
||||
\ccc{CGAL::Triangulation_cell_base_with_info_3}
|
||||
\ccc{CGAL::Triangulation_cell_base_with_circumcenter_3}
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,12 @@ The second template argument is a combinatorial cell base class from which
|
|||
\ccc{Triangulation_cell_base_3} derives.
|
||||
It has the default value \ccc{Triangulation_ds_cell_base_3<>}.
|
||||
|
||||
Note that this model does not store the circumcenter, but computes it
|
||||
every time the circumcenter function is called. See
|
||||
\ccc{CGAL::Triangulation_cell_base_with_circumcenter_3} for a way to cache the
|
||||
circumcenter computation.
|
||||
|
||||
|
||||
\ccIsModel \ccc{TriangulationCellBase_3}
|
||||
|
||||
\ccInheritsFrom \ccc{TriangulationDSCellBase_3}
|
||||
|
|
@ -41,6 +47,7 @@ It has the default value \ccc{Triangulation_ds_cell_base_3<>}.
|
|||
|
||||
\ccc{CGAL::Triangulation_ds_cell_base_3}\\
|
||||
\ccc{CGAL::Triangulation_cell_base_with_info_3}\\
|
||||
\ccc{CGAL::Triangulation_cell_base_with_circumcenter_3}\\
|
||||
\ccc{CGAL::Triangulation_vertex_base_3}
|
||||
|
||||
\end{ccRefClass}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
% +------------------------------------------------------------------------+
|
||||
% | Reference manual page: Triangulation_cell_base_with_circumcenter_3.tex
|
||||
% +------------------------------------------------------------------------+
|
||||
% | 29.3.2000 Sylvain Pion
|
||||
% | Package: Triangulation3
|
||||
% |
|
||||
\RCSdef{\RCSTriangulationcellbaseRev}{$Id$}
|
||||
\RCSdefDate{\RCSTriangulationcellbaseDate}{$Date$}
|
||||
% |
|
||||
%%RefPage: end of header, begin of main body
|
||||
% +------------------------------------------------------------------------+
|
||||
|
||||
|
||||
\begin{ccRefClass}{Triangulation_cell_base_with_circumcenter_3<DelaunayTriangulationTraits_3, TriangulationCellBase_3>}
|
||||
|
||||
\ccDefinition
|
||||
|
||||
The class \ccc{Triangulation_cell_base_with_circumcenter_3} is a model of the
|
||||
concept \ccc{TriangulationCellBase_3}, the base cell of a 3D-triangulation.
|
||||
It provides an easy way to cache the computation of the circumcenter of
|
||||
tetrahedra.
|
||||
Note that input/output operators discard this additional information.
|
||||
|
||||
All functions modifying the vertices of the cell, invalidate the cached
|
||||
circumcenter.
|
||||
|
||||
\ccInclude{CGAL/Triangulation_cell_base_with_circumcenter_3.h}
|
||||
|
||||
\ccParameters
|
||||
|
||||
The first template argument is the geometric traits class
|
||||
\ccc{DelaunayTriangulationTraits_3}.
|
||||
|
||||
The second template argument is a cell base class from which
|
||||
\ccc{Triangulation_cell_base_with_circumcenter_3} derives.
|
||||
It has the default value \ccc{Triangulation_cell_base_3<DelaunayTriangulationTraits_3>}.
|
||||
|
||||
\ccIsModel \ccc{TriangulationCellBase_3}
|
||||
|
||||
\ccInheritsFrom \ccc{TriangulationCellBase_3}
|
||||
|
||||
%\ccTypes
|
||||
%\ccTypedef{typedef Info Info;}{}
|
||||
|
||||
\ccCreationVariable{v}
|
||||
|
||||
\ccAccessFunctions
|
||||
\ccThree{const Info&}{Facetxxxxxxxx}{}
|
||||
\ccTagFullDeclarations
|
||||
|
||||
\ccMethod{const DelaunayTriangulationTraits_3::Point_3& circumcenter(
|
||||
const DelaunayTriangulationTraits_3> = DelaunayTriangulationTraits_3()) const;}
|
||||
{Computes the circumcenter of the tetrahedron, or retrieve it if already
|
||||
computed.}
|
||||
|
||||
\ccSeeAlso
|
||||
|
||||
\ccc{CGAL::Triangulation_cell_base_3}\\
|
||||
\ccc{CGAL::Triangulation_cell_base_with_info_3}
|
||||
|
||||
\end{ccRefClass}
|
||||
|
|
@ -56,6 +56,7 @@ The third template argument is a cell base class from which
|
|||
\ccSeeAlso
|
||||
|
||||
\ccc{CGAL::Triangulation_cell_base_3}\\
|
||||
\ccc{CGAL::Triangulation_cell_base_with_circumcenter_3}
|
||||
\ccc{CGAL::Triangulation_vertex_base_with_info_3}
|
||||
|
||||
\end{ccRefClass}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ Figure~\ref{Triangulation3-fig-orient}.
|
|||
|
||||
\ccRefIdfierPage{CGAL::Triangulation_cell_base_3<TriangulationTraits_3, TriangulationDSCellBase_3>}\\
|
||||
\ccRefIdfierPage{CGAL::Triangulation_cell_base_with_info_3<Info, TriangulationTraits_3, TriangulationCellBase_3>}\\
|
||||
\ccRefIdfierPage{CGAL::Triangulation_cell_base_with_circumcenter_3<DelaunayTriangulationTraits_3, TriangulationCellBase_3>}\\
|
||||
\ccRefIdfierPage{CGAL::Triangulation_vertex_base_3<TriangulationTraits_3, TriangulationDSVertexBase_3>}\\
|
||||
\ccRefIdfierPage{CGAL::Triangulation_vertex_base_with_info_3<Info, TriangulationTraits_3, TriangulationVertexBase_3>}\\
|
||||
\ccRefIdfierPage{CGAL::Triangulation_hierarchy_vertex_base_3<TriangulationVertexBase_3>}\\
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
\input{Triangulation_3_ref/Triangulation_cell_base_3.tex}
|
||||
\input{Triangulation_3_ref/Triangulation_cell_base_with_info_3.tex}
|
||||
\input{Triangulation_3_ref/Triangulation_cell_base_with_circumcenter_3.tex}
|
||||
\input{Triangulation_3_ref/Triangulation_vertex_base_3.tex}
|
||||
\input{Triangulation_3_ref/Triangulation_vertex_base_with_info_3.tex}
|
||||
\input{Triangulation_3_ref/Triangulation_hierarchy_vertex_base_3.tex}
|
||||
|
|
|
|||
|
|
@ -134,13 +134,6 @@ protected:
|
|||
return geom_traits().construct_circumcenter_3_object()(p, q, r);
|
||||
}
|
||||
|
||||
Point
|
||||
construct_circumcenter(const Point &p, const Point &q,
|
||||
const Point &r, const Point &s) const
|
||||
{
|
||||
return geom_traits().construct_circumcenter_3_object()(p, q, r, s);
|
||||
}
|
||||
|
||||
Line
|
||||
construct_equi_distant_line(const Point &p1, const Point &p2,
|
||||
const Point &p3) const
|
||||
|
|
@ -1388,10 +1381,7 @@ dual(Cell_handle c) const
|
|||
{
|
||||
CGAL_triangulation_precondition(dimension()==3);
|
||||
CGAL_triangulation_precondition( ! is_infinite(c) );
|
||||
return construct_circumcenter( c->vertex(0)->point(),
|
||||
c->vertex(1)->point(),
|
||||
c->vertex(2)->point(),
|
||||
c->vertex(3)->point() );
|
||||
return c->circumcenter(geom_traits());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// Copyright (c) 1999 INRIA Sophia-Antipolis (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
|
|
@ -17,6 +16,7 @@
|
|||
//
|
||||
//
|
||||
// Author(s) : Monique Teillaud <Monique.Teillaud@sophia.inria.fr>
|
||||
// Sylvain Pion
|
||||
|
||||
// cell of a triangulation of any dimension <=3
|
||||
|
||||
|
|
@ -67,6 +67,16 @@ public:
|
|||
Point_iterator hidden_points_begin() const { return hidden_points_end(); }
|
||||
Point_iterator hidden_points_end() const { return NULL; }
|
||||
void hide_point (const Point &p) const { }
|
||||
|
||||
typename Geom_traits::Point_3
|
||||
circumcenter(const Geom_traits& gt = Geom_traits()) const
|
||||
{
|
||||
return gt.construct_circumcenter_3_object()(this->vertex(0)->point(),
|
||||
this->vertex(1)->point(),
|
||||
this->vertex(2)->point(),
|
||||
this->vertex(3)->point());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// The following should be useless.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,137 @@
|
|||
// Copyright (c) 1999-2006 INRIA Sophia-Antipolis (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you may redistribute it under
|
||||
// the terms of the Q Public License version 1.0.
|
||||
// See the file LICENSE.QPL distributed with CGAL.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $Source: /CVSROOT/CGAL/Packages/Triangulation_3/include/CGAL/Triangulation_cell_base_3.h,v $
|
||||
// $Revision$ $Date$
|
||||
// $Name: $
|
||||
//
|
||||
// Author(s) : Monique Teillaud <Monique.Teillaud@sophia.inria.fr>
|
||||
// Sylvain Pion
|
||||
|
||||
// cell of a triangulation of any dimension <=3,
|
||||
// storing its circumcenter lazily.
|
||||
|
||||
#ifndef CGAL_TRIANGULATION_CELL_BASE_WITH_CIRCUMCENTER_3_H
|
||||
#define CGAL_TRIANGULATION_CELL_BASE_WITH_CIRCUMCENTER_3_H
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/triangulation_assertions.h>
|
||||
#include <CGAL/Triangulation_short_names_3.h>
|
||||
#include <CGAL/Triangulation_ds_cell_base_3.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
template < typename GT, typename Cb = Triangulation_ds_cell_base_3<> >
|
||||
class Triangulation_cell_base_with_circumcenter_3
|
||||
: public Cb
|
||||
{
|
||||
typedef typename GT::Point_3 Point_3;
|
||||
|
||||
mutable Point_3 * circumcenter_;
|
||||
|
||||
void invalidate_circumcenter()
|
||||
{
|
||||
if (circumcenter_) {
|
||||
delete circumcenter_;
|
||||
circumcenter_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
typedef typename Cb::Vertex_handle Vertex_handle;
|
||||
typedef typename Cb::Cell_handle Cell_handle;
|
||||
|
||||
typedef GT Geom_traits;
|
||||
|
||||
template < typename TDS2 >
|
||||
struct Rebind_TDS {
|
||||
typedef typename Cb::template Rebind_TDS<TDS2>::Other Cb2;
|
||||
typedef Triangulation_cell_base_with_circumcenter_3<GT, Cb2> Other;
|
||||
};
|
||||
|
||||
Triangulation_cell_base_with_circumcenter_3()
|
||||
: Cb(), circumcenter_(NULL) {}
|
||||
|
||||
Triangulation_cell_base_with_circumcenter_3
|
||||
(const Triangulation_cell_base_with_circumcenter_3 &c)
|
||||
{
|
||||
if (c.circumcenter_ != NULL)
|
||||
circumcenter_ = new Point_3(*circumcenter_);
|
||||
else
|
||||
circumcenter_ = NULL;
|
||||
}
|
||||
|
||||
Triangulation_cell_base_with_circumcenter_3&
|
||||
operator=(const Triangulation_cell_base_with_circumcenter_3 &c)
|
||||
{
|
||||
Triangulation_cell_base_with_circumcenter_3 tmp=c;
|
||||
std::swap(tmp, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Triangulation_cell_base_with_circumcenter_3(
|
||||
const Vertex_handle& v0, const Vertex_handle& v1,
|
||||
const Vertex_handle& v2, const Vertex_handle& v3)
|
||||
: Cb(v0, v1, v2, v3), circumcenter_(NULL) {}
|
||||
|
||||
Triangulation_cell_base_with_circumcenter_3(
|
||||
const Vertex_handle& v0, const Vertex_handle& v1,
|
||||
const Vertex_handle& v2, const Vertex_handle& v3,
|
||||
const Cell_handle& n0, const Cell_handle& n1,
|
||||
const Cell_handle& n2, const Cell_handle& n3)
|
||||
: Cb(v0, v1, v2, v3, n0, n1, n2, n3), circumcenter_(NULL) {}
|
||||
|
||||
~Triangulation_cell_base_with_circumcenter_3()
|
||||
{
|
||||
delete circumcenter_;
|
||||
}
|
||||
|
||||
// We must override the functions that modify the vertices.
|
||||
// And if the point inside a vertex is modified, we fail,
|
||||
// but there's not much we can do for this now.
|
||||
void set_vertex(int i, const Vertex_handle& v)
|
||||
{
|
||||
invalidate_circumcenter();
|
||||
Cb::set_vertex(i, v);
|
||||
}
|
||||
|
||||
void set_vertices()
|
||||
{
|
||||
invalidate_circumcenter();
|
||||
Cb::set_vertices();
|
||||
}
|
||||
|
||||
void set_vertices(const Vertex_handle& v0, const Vertex_handle& v1,
|
||||
const Vertex_handle& v2, const Vertex_handle& v3)
|
||||
{
|
||||
invalidate_circumcenter();
|
||||
Cb::set_vertices(v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
const Point_3 &
|
||||
circumcenter(const Geom_traits& gt = Geom_traits()) const
|
||||
{
|
||||
if (circumcenter_ == NULL) {
|
||||
circumcenter_ = new Point_3(
|
||||
gt.construct_circumcenter_3_object()(this->vertex(0)->point(),
|
||||
this->vertex(1)->point(),
|
||||
this->vertex(2)->point(),
|
||||
this->vertex(3)->point()));
|
||||
}
|
||||
return *circumcenter_;
|
||||
}
|
||||
};
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_TRIANGULATION_CELL_BASE_WITH_CIRCUMCENTER_3_H
|
||||
|
|
@ -15,7 +15,7 @@ include $(CGAL_MAKEFILE)
|
|||
|
||||
CXXFLAGS = \
|
||||
-I../../include \
|
||||
-I../../../Kernel_23/include \
|
||||
-I$(HOME)/CGAL/trunk/Kernel_23/include \
|
||||
$(TESTSUITE_CXXFLAGS) \
|
||||
$(EXTRA_FLAGS) \
|
||||
$(CGAL_CXXFLAGS) \
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
// Author(s) : Francois Rebufat
|
||||
|
||||
#include <CGAL/Delaunay_triangulation_3.h>
|
||||
#include <CGAL/Triangulation_cell_base_with_circumcenter_3.h>
|
||||
|
||||
bool del=true;
|
||||
|
||||
|
|
@ -30,6 +31,14 @@ int main()
|
|||
|
||||
_test_cls_delaunay_3( Cls() );
|
||||
|
||||
// Second version for the circumcenter storing cell base class.
|
||||
typedef CGAL::Triangulation_vertex_base_3<K> Vb;
|
||||
typedef CGAL::Triangulation_cell_base_with_circumcenter_3<K> Cb;
|
||||
typedef CGAL::Triangulation_data_structure_3<Vb, Cb> TDS;
|
||||
typedef CGAL::Delaunay_triangulation_3<K, TDS> Cls_circumcenter;
|
||||
|
||||
_test_cls_delaunay_3( Cls_circumcenter() );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue