add class Has_timestamp not to modify the API of Compact_container

- use the Has_timestamp operator in Compact_container
- add partial specialization to classes that need the time stamp (i.e.
Mesh_vertex_base, Compact_mesh_cell_base_3 and Mesh_cell_base_3)
- remove "ts" from classes where they were actually needed for compilation
purpose only (i.e. Kd_tree_node and Triangulation_ds_cell_base_3)
- rename "ts" to time_stamp_
This commit is contained in:
Jane Tournois 2014-02-20 15:53:36 +01:00
parent c7eabc4f64
commit 0740b3652f
7 changed files with 84 additions and 13 deletions

View File

@ -28,6 +28,8 @@
#include <CGAL/basic.h>
#include <CGAL/triangulation_assertions.h>
#include <CGAL/internal/Dummy_tds_3.h>
#include <CGAL/tags.h>
#include <CGAL/Mesh_3/Has_timestamp.h>
#include <CGAL/Regular_triangulation_cell_base_3.h>
#include <CGAL/Mesh_3/io_signature.h>
@ -499,10 +501,18 @@ private:
mutable bool sliver_cache_validity_;
public:
std::size_t ts;
std::size_t time_stamp_;
}; // end class Compact_mesh_cell_base_3
namespace internal {
namespace Mesh_3 {
template < class GT, class MT, class Cb >
struct Has_timestamp< Compact_mesh_cell_base_3<GT, MT, Cb> >
: public CGAL::Tag_true
{};
} // end namespace internal::Mesh_3
} // end namespace internal
template < class GT, class MT, class Cb >

View File

@ -0,0 +1,43 @@
// Copyright (c) 2009 INRIA Sophia-Antipolis (France).
// Copyright (c) 2014 GeometryFactory Sarl (France)
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// 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.
//
//
//
// Author(s) : Jane Tournois
#ifndef CGAL_MESH_3_HAS_TIMESTAMP_H
#define CGAL_MESH_3_HAS_TIMESTAMP_H
#include <boost/mpl/has_xxx.hpp>
#include <CGAL/tags.h>
namespace CGAL {
namespace internal {
namespace Mesh_3 {
// to have Mesh_3 deterministic,
// a partial specialization of this class should be written next to
// every class that implements concepts MeshCellBase_3 or MeshVertexBase_3
template <typename T>
struct Has_timestamp : public CGAL::Tag_false
// when T does not have a partial specialization of Has_timestamp
{};
} // end namespace internal::Mesh_3
} // end namespace internal
} // end namespace CGAL
#endif // CGAL_MESH_3_HAS_TIMESTAMP_H

View File

@ -33,6 +33,8 @@
#include <CGAL/Triangulation_cell_base_with_circumcenter_3.h>
#include <CGAL/Mesh_3/Mesh_surface_cell_base_3.h>
#include <CGAL/Mesh_3/io_signature.h>
#include <CGAL/Mesh_3/Has_timestamp.h>
#include <CGAL/tags.h>
namespace CGAL {
@ -169,8 +171,19 @@ private:
Cell_handle next_intrusive_, previous_intrusive_;
#endif
public:
std::size_t time_stamp_;
}; // end class Mesh_cell_base_3
namespace internal {
namespace Mesh_3 {
template < class GT, class MT, class Cb >
struct Has_timestamp< Mesh_cell_base_3<GT, MT, Cb> >
: public CGAL::Tag_true
{};
} // end namespace internal::Mesh_3
} // end namespace internal
template < class GT, class MT, class Cb >

View File

@ -30,9 +30,10 @@
#define CGAL_COMPACT_MESH_VERTEX_BASE_3_H
#include <CGAL/Triangulation_vertex_base_3.h>
#include <CGAL/Mesh_3/Has_features.h>
#include <CGAL/internal/Mesh_3/get_index.h>
#include <CGAL/Mesh_3/io_signature.h>
#include <CGAL/Mesh_3/Has_timestamp.h>
#include <CGAL/tags.h>
namespace CGAL {
@ -160,7 +161,7 @@ public:
}
public:
std::size_t ts;
std::size_t time_stamp_;
private:
@ -187,6 +188,10 @@ private:
namespace internal {
namespace Mesh_3 {
template < class GT, class MT, class Vb >
struct Has_timestamp< Mesh_vertex_base_3<GT, MT, Vb> >
: public CGAL::Tag_true
{};
} // end namespace internal::Mesh_3
} // end namespace internal

View File

@ -30,6 +30,7 @@
#include <CGAL/memory.h>
#include <CGAL/iterator.h>
#include <CGAL/Mesh_3/Has_timestamp.h>
#include <boost/mpl/if.hpp>
@ -121,8 +122,8 @@ public:
CGAL_time_stamper(const CGAL_time_stamper& ts)
: time_stamp_(ts.time_stamp_) {}
void set_time_stamp(T* pt) { pt->ts = time_stamp_++; }
static std::size_t get(T* pt) { return pt->ts; }
void set_time_stamp(T* pt) { pt->time_stamp_ = time_stamp_++; }
static std::size_t get(T* pt) { return pt->time_stamp_; }
void reset() { time_stamp_ = 0; }
std::size_t time_stamp_;
@ -147,7 +148,8 @@ class Compact_container
typedef typename Default::Get< Al, CGAL_ALLOCATOR(T) >::type Allocator;
typedef TimeStamper_ Ts;
typedef typename boost::mpl::if_c< true,// CGAL::has_timestamp<T>,
typedef typename boost::mpl::if_c<
CGAL::internal::Mesh_3::Has_timestamp<T>::value,
typename CGAL_time_stamper<T>,
typename CGAL_no_time_stamp<T> >::type Time_stamper_;
typedef typename Default::Get<Ts, Time_stamper_>::type Time_stamper;

View File

@ -24,6 +24,8 @@
#include <CGAL/Splitters.h>
#include <CGAL/Compact_container.h>
#include <CGAL/tags.h>
namespace CGAL {
template <class SearchTraits, class Splitter, class UseExtendedNode>
@ -61,9 +63,6 @@ namespace CGAL {
// private variables for extended internal nodes
FT low_val;
FT high_val;
public:
std::size_t ts;
public:
@ -75,11 +74,11 @@ namespace CGAL {
{}
Kd_tree_node(Node_type t )
: the_node_type(t) , ts(0)
: the_node_type(t)
{}
Kd_tree_node(unsigned int n_, Node_type t )
: the_node_type(t), n(n_), ts(0)
: the_node_type(t), n(n_)
{}
// members for all nodes

View File

@ -26,6 +26,7 @@
#include <CGAL/basic.h>
#include <CGAL/triangulation_assertions.h>
#include <CGAL/internal/Dummy_tds_3.h>
#include <CGAL/tags.h>
namespace CGAL {
@ -207,8 +208,6 @@ private:
Cell_handle N[4];
Vertex_handle V[4];
TDS_data _tds_data;
public:
std::size_t ts;
};
template < class TDS >