Skip to content

Commit

Permalink
Merge pull request #7423 from lrineau/Triangulation_3-fix_simplex_tra…
Browse files Browse the repository at this point in the history
…verser-GF

Triangulation_3: Fix a bug in tr.segment_traverser_simplices()
  • Loading branch information
lrineau committed Jul 5, 2023
2 parents ed44ef8 + 4b18c72 commit 700d4da
Show file tree
Hide file tree
Showing 11 changed files with 1,143 additions and 745 deletions.
48 changes: 48 additions & 0 deletions STL_Extension/include/CGAL/Base_with_time_stamp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) 2023 GeometryFactory Sarl (France).
// All rights reserved.
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Laurent Rineau

#ifndef CGAL_BASE_WITH_TIME_STAMP_H
#define CGAL_BASE_WITH_TIME_STAMP_H

#include <CGAL/tags.h> // for Tag_true
#include <cstdint> // for std::size_t
#include <utility> // for std::forward

namespace CGAL {

template <typename Base>
class Base_with_time_stamp : public Base {
std::size_t time_stamp_ = -1;
public:
using Base::Base;

Base_with_time_stamp(const Base_with_time_stamp& other) :
Base(other),
time_stamp_(other.time_stamp_)
{}

typedef CGAL::Tag_true Has_timestamp;

std::size_t time_stamp() const {
return time_stamp_;
}
void set_time_stamp(const std::size_t& ts) {
time_stamp_ = ts;
}

template < class TDS >
struct Rebind_TDS {
typedef typename Base::template Rebind_TDS<TDS>::Other Base2;
typedef Base_with_time_stamp<Base2> Other;
};
};

} // namespace CGAL

#endif // CGAL_BASE_WITH_TIME_STAMP_H
7 changes: 7 additions & 0 deletions STL_Extension/include/CGAL/Iterator_range.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ namespace CGAL {
{
return std::tuple<const I&, const I&>{this->first, this->second};
}

template <template<class...> class Container>
auto to() const
{
using V = std::remove_cv_t<std::remove_reference_t<decltype(*begin())>>;
return Container<V>(begin(), end());
}
};

template <typename T>
Expand Down
7 changes: 5 additions & 2 deletions TDS_3/include/CGAL/Triangulation_simplex_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ class Triangulation_simplex_3 {

// returns the dimension of the simplex
int dimension () const {
return (ref & 3);
if(ref == -1) return -1;
else return (ref & 3);
}

// returns an incident cell:
Cell_handle incident_cell() {
return ch;
Expand Down Expand Up @@ -161,6 +163,7 @@ operator==(Triangulation_simplex_3<TriangulationDataStructure_3> s0,
typename Sim::Cell_handle neighbor;

switch (s0.dimension()) {
case -1: return s1.dimension() == -1;
case (0): // Vertex
return (s0.ch->vertex(s0.index(0)) == s1.ch->vertex(s1.index(0)));
case (1): // Edge
Expand All @@ -180,7 +183,7 @@ operator==(Triangulation_simplex_3<TriangulationDataStructure_3> s0,
}
return false;
case (3):
return (&(*s0.ch) == &(*s1.ch));
return s0.ch.operator->() == s1.ch.operator->();
}
CGAL_error();
return false;
Expand Down
31 changes: 2 additions & 29 deletions Triangulation_2/test/Triangulation_2/issue_4405.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,20 @@
#include <CGAL/Projection_traits_xy_3.h>
#include <CGAL/Triangulation_face_base_with_info_2.h>
#include <CGAL/Triangulation_vertex_base_with_id_2.h>
#include <CGAL/Base_with_time_stamp.h>

typedef CGAL::Epick Kernel;
typedef Kernel::FT FieldNumberType;
typedef Kernel::Point_2 Point2;
typedef Kernel::Point_3 Point3;

template <typename Vb>
class My_vertex_base : public Vb {
std::size_t time_stamp_;
public:
My_vertex_base() : Vb(), time_stamp_(-1) {
}

My_vertex_base(const My_vertex_base& other) :
Vb(other),
time_stamp_(other.time_stamp_)
{}

typedef CGAL::Tag_true Has_timestamp;

std::size_t time_stamp() const {
return time_stamp_;
}
void set_time_stamp(const std::size_t& ts) {
time_stamp_ = ts;
}

template < class TDS >
struct Rebind_TDS {
typedef typename Vb::template Rebind_TDS<TDS>::Other Vb2;
typedef My_vertex_base<Vb2> Other;
};
};

struct FaceInfo2
{
unsigned long long m_id;
};
typedef CGAL::Projection_traits_xy_3<Kernel> TriangulationTraits;
typedef CGAL::Triangulation_vertex_base_with_id_2<TriangulationTraits> VertexBaseWithId;
typedef My_vertex_base<VertexBaseWithId> Vb2;
typedef CGAL::Base_with_time_stamp<VertexBaseWithId> Vb2;
typedef CGAL::Triangulation_vertex_base_2<TriangulationTraits, Vb2> VertexBase;
typedef CGAL::Triangulation_face_base_with_info_2<FaceInfo2, Kernel> FaceBaseWithInfo;
typedef CGAL::Constrained_triangulation_face_base_2<TriangulationTraits, FaceBaseWithInfo> FaceBase;
Expand Down
31 changes: 2 additions & 29 deletions Triangulation_2/test/Triangulation_2/test_cdt_degenerate_case.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,14 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Constrained_triangulation_plus_2.h>
#include <CGAL/Base_with_time_stamp.h>
#include <iostream>

typedef CGAL::Exact_predicates_inexact_constructions_kernel EPIC;
typedef EPIC::Point_2 Point_2;

template <typename Vb>
class My_vertex_base : public Vb {
std::size_t time_stamp_;
public:
My_vertex_base() : Vb(), time_stamp_(-1) {
}

My_vertex_base(const My_vertex_base& other) :
Vb(other),
time_stamp_(other.time_stamp_)
{}

typedef CGAL::Tag_true Has_timestamp;

std::size_t time_stamp() const {
return time_stamp_;
}
void set_time_stamp(const std::size_t& ts) {
time_stamp_ = ts;
}

template < class TDS >
struct Rebind_TDS {
typedef typename Vb::template Rebind_TDS<TDS>::Other Vb2;
typedef My_vertex_base<Vb2> Other;
};
};

#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
typedef My_vertex_base<CGAL::Triangulation_vertex_base_2<EPIC> > Vb;
typedef CGAL::Base_with_time_stamp<CGAL::Triangulation_vertex_base_2<EPIC> > Vb;
#else
typedef CGAL::Triangulation_vertex_base_2<K> Vb;
#endif
Expand Down
Loading

0 comments on commit 700d4da

Please sign in to comment.