Merge branch 'releases/CGAL-5.0-branch' into 5.1.x-branch

This commit is contained in:
Laurent Rineau 2020-10-21 09:27:51 +02:00
commit 16a929c310
4 changed files with 227 additions and 7 deletions

View File

@ -56,7 +56,7 @@ namespace internal {
int n;
Indentation_level() : n(0) {}
friend std::ostream& operator<<(std::ostream& os, Indentation_level level) {
return os << std::string(2*level.n, ' ');
return os << std::setw(2) << level.n << ": " << std::string(2*level.n, ' ');
}
Indentation_level& operator++() { ++n; return *this; }
Indentation_level& operator--() { --n; return *this; }
@ -843,11 +843,11 @@ insert_constraint(Vertex_handle vaa, Vertex_handle vbb)
if (vi != vaa && vi != vbb) {
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_2::insert_constraint stask push [vaa, vi] ( #" << vaa->time_stamp() << "= " << vaa->point()
<< "CT_2::insert_constraint stack push [vaa, vi] ( #" << vaa->time_stamp() << "= " << vaa->point()
<< " , #" << vi->time_stamp() << "= " << vi->point()
<< " )\n";
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_2::insert_constraint stask push [vi, vbb] ( #" << vi->time_stamp() << "= " << vi->point()
<< "CT_2::insert_constraint stack push [vi, vbb] ( #" << vi->time_stamp() << "= " << vi->point()
<< " , #" << vbb->time_stamp() << "= " << vbb->point()
<< " )\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
@ -857,7 +857,7 @@ insert_constraint(Vertex_handle vaa, Vertex_handle vbb)
else{
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_2::insert_constraint stask push [vaa, vbb]( #" << vaa->time_stamp() << "= " << vaa->point()
<< "CT_2::insert_constraint stack push [vaa, vbb]( #" << vaa->time_stamp() << "= " << vaa->point()
<< " , #" << vbb->time_stamp() << "= " << vbb->point()
<< " )\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS

View File

@ -278,6 +278,12 @@ public:
Constraint_id insert_constraint(Vertex_handle va, Vertex_handle vb)
{
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::insert_constraint( #" << va->time_stamp() << "= " << va->point()
<< " , #" << vb->time_stamp() << "= " << vb->point()
<< " )\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
// protects against inserting a zero length constraint
if(va == vb){
return Constraint_id(nullptr);
@ -880,6 +886,17 @@ insert_subconstraint(Vertex_handle vaa,
// insert the subconstraint [vaa vbb]
// it will eventually be split into several subconstraints
{
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::insert_subconstraint( #" << vaa->time_stamp() << "= " << vaa->point()
<< " , #" << vbb->time_stamp() << "= " << vbb->point()
<< " )\n";
internal::Indentation_level::Exit_guard exit_guard = CGAL::internal::cdt_2_indent_level.open_new_scope();
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::insert_constraint stack push [va, vb] ( #" << vaa->time_stamp() << "= " << vaa->point()
<< " , #" << vbb->time_stamp() << "= " << vbb->point()
<< " )\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
std::stack<std::pair<Vertex_handle, Vertex_handle> > stack;
stack.push(std::make_pair(vaa,vbb));
@ -887,15 +904,36 @@ insert_subconstraint(Vertex_handle vaa,
boost::tie(vaa,vbb) = stack.top();
stack.pop();
CGAL_triangulation_precondition( vaa != vbb);
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::insert_subconstraint, stack pop=( #" << vaa->time_stamp() << "= " << vaa->point()
<< " , #" << vbb->time_stamp() << "= " << vbb->point()
<< " ) remaining stack size: "
<< stack.size() << '\n';
CGAL_assertion(this->is_valid());
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
Vertex_handle vi;
Face_handle fr;
int i;
if(this->includes_edge(vaa,vbb,vi,fr,i)) {
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::insert_subconstraint, the segment ( #" << vaa->time_stamp() << "= " << vaa->point()
<< " , #" << vbb->time_stamp() << "= " << vbb->point()
<< " ) is an edge with #"
<< vi->time_stamp() << "= " << vi->point()
<< '\n';
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
this->mark_constraint(fr,i);
if (vi != vbb) {
hierarchy.split_constraint(vaa,vbb,vi);
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::insert_constraint (includes_edge) stack push [vi, vbb] ( #" << vi->time_stamp() << "= " << vi->point()
<< " , #" << vbb->time_stamp() << "= " << vbb->point()
<< " )\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
stack.push(std::make_pair(vi,vbb));
}
continue;
@ -914,10 +952,28 @@ insert_subconstraint(Vertex_handle vaa,
if ( intersection) {
if (vi != vaa && vi != vbb) {
hierarchy.split_constraint(vaa,vbb,vi);
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::insert_constraint stack push [vaa, vi] ( #" << vaa->time_stamp() << "= " << vaa->point()
<< " , #" << vi->time_stamp() << "= " << vi->point()
<< " )\n";
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::insert_constraint stack push [vi, vbb] ( #" << vi->time_stamp() << "= " << vi->point()
<< " , #" << vbb->time_stamp() << "= " << vbb->point()
<< " )\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
stack.push(std::make_pair(vaa,vi));
stack.push(std::make_pair(vi,vbb));
}
else stack.push(std::make_pair(vaa,vbb));
else {
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::insert_constraint stack push [vaa, vbb]( #" << vaa->time_stamp() << "= " << vaa->point()
<< " , #" << vbb->time_stamp() << "= " << vbb->point()
<< " )\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
stack.push(std::make_pair(vaa,vbb));
}
continue;
}
@ -1057,6 +1113,14 @@ insert(const Point& a, Locate_type lt, Face_handle loc, int li)
Vertex_handle va = Triangulation::insert(a,lt,loc,li);
// update the hierarchy
if (insert_in_constrained_edge) {
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< " CT_plus_2::insert(" << a << ") = #"
<< va->time_stamp()
<< " insert in constrained edge: #" << v1->time_stamp() << "= " << v1->point()
<< " , #" << v2->time_stamp() << "= " << v2->point()
<< std::endl;
#endif
hierarchy.split_constraint(v1,v2,va);
}
return va;
@ -1124,6 +1188,14 @@ intersect(Face_handle f, int i,
const Point& pb = vb->point();
const Point& pc = vc->point();
const Point& pd = vd->point();
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::intersect segment ( #" << va->time_stamp() << "= " << va->point()
<< " , #" << vb->time_stamp() << "= " << vb->point()
<< " ) with edge ( #"<< vc->time_stamp() << "= " << vc->point()
<< " , #" << vd->time_stamp() << "= " << vd->point()
<< " , Exact_intersections_tag)\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
Point pi;
Intersection_tag itag = Intersection_tag();
CGAL_triangulation_assertion_code( bool ok = )
@ -1131,6 +1203,11 @@ intersect(Face_handle f, int i,
CGAL_triangulation_assertion(ok);
Vertex_handle vi = insert(pi, Triangulation::EDGE, f, i);
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::intersect, `vi` is ( #" << vi->time_stamp() << "= " << vi->point()
<< " )\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
return vi;
}
@ -1150,6 +1227,14 @@ intersect(Face_handle f, int i,
const Point& pb = vbb->point();
const Point& pc = vcc->point();
const Point& pd = vdd->point();
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::intersect segment ( #" << vaa->time_stamp() << "= " << vaa->point()
<< " , #" << vbb->time_stamp() << "= " << vbb->point()
<< " ) with edge ( #"<< vcc->time_stamp() << "= " << vcc->point()
<< " , #" << vdd->time_stamp() << "= " << vdd->point()
<< " , Exact_predicates_tag)\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
Point pi; //creator for point is required here
Intersection_tag itag = Intersection_tag();
@ -1172,6 +1257,11 @@ intersect(Face_handle f, int i,
Triangulation::remove_constrained_edge(f, i);
vi = insert(pi, f);
}
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "CT_plus_2::intersect, `vi` is ( #" << vi->time_stamp() << "= " << vi->point()
<< " )\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
// vi == vc or vi == vd may happen even if intersection==true
// due to approximate construction of the intersection

View File

@ -24,6 +24,10 @@
#include <CGAL/Skiplist.h>
#include <CGAL/triangulation_assertions.h>
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
# include <CGAL/Constrained_triangulation_2.h>
#endif
namespace CGAL {
// T is expected to be Vertex_handle
@ -840,6 +844,14 @@ insert_constraint(T va, T vb){
Vertex_list* children = new Vertex_list;
Context_list* fathers;
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "C_hierachy.insert_constraint( #"
<< va->time_stamp()
<< ", #"
<< vb->time_stamp()
<< ")\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
typename Sc_to_c_map::iterator scit = sc_to_c_map.find(he);
if(scit == sc_to_c_map.end()){
fathers = new Context_list;
@ -869,6 +881,14 @@ insert_constraint_old_API(T va, T vb){
Vertex_list* children = new Vertex_list;
Context_list* fathers;
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "C_hierachy.insert_constraint_old_API( #"
<< va->time_stamp()
<< ", #"
<< vb->time_stamp()
<< ")\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
typename Sc_to_c_map::iterator scit = sc_to_c_map.find(he);
if(scit == sc_to_c_map.end()){
fathers = new Context_list;
@ -896,6 +916,14 @@ append_constraint(Constraint_id cid, T va, T vb){
Edge he = make_edge(va, vb);
Context_list* fathers;
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "C_hierachy.append_constraint( ..., #"
<< va->time_stamp()
<< ", #"
<< vb->time_stamp()
<< ")\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
typename Sc_to_c_map::iterator scit = sc_to_c_map.find(he);
if(scit == sc_to_c_map.end()){
fathers = new Context_list;
@ -1007,8 +1035,24 @@ template <class T, class Compare, class Point>
void
Polyline_constraint_hierarchy_2<T,Compare,Point>::
add_Steiner(T va, T vb, T vc){
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< "C_hierachy.add_Steinter( #"
<< va->time_stamp()
<< ", #"
<< vb->time_stamp()
<< ", #"
<< vc->time_stamp()
<< ")\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
Context_list* hcl=nullptr;
if(!get_contexts(va,vb,hcl)) CGAL_triangulation_assertion(false);
if(!get_contexts(va,vb,hcl)) {
#ifdef CGAL_CDT_2_DEBUG_INTERSECTIONS
std::cerr << CGAL::internal::cdt_2_indent_level
<< " -> the constraint is already split\n";
#endif // CGAL_CDT_2_DEBUG_INTERSECTIONS
return;
}
Context_list* hcl2 = new Context_list;

View File

@ -0,0 +1,86 @@
// clang++ a01.cpp -o a01 -I/home/jherring/code/dev/third-party/current/include -lgmp -lmpfr
#include <CGAL/Triangulation_hierarchy_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Triangulation_face_base_with_info_2.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Constrained_triangulation_plus_2.h>
template<typename VertexInfoType, typename FaceInfoType, typename Itag>
struct TriangulationTraitsTemplate_2 {
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
using Vbb = CGAL::Triangulation_vertex_base_with_info_2<VertexInfoType, K>;
using Vb = CGAL::Triangulation_hierarchy_vertex_base_2<Vbb>;
using Fbb = CGAL::Triangulation_face_base_with_info_2<FaceInfoType, K>;
using Fb = CGAL::Constrained_triangulation_face_base_2<K, Fbb>;
using TDS = CGAL::Triangulation_data_structure_2<Vb, Fb>;
using CDTBase = CGAL::Constrained_Delaunay_triangulation_2<K, TDS, Itag>;
using CDTHierarchy = CGAL::Triangulation_hierarchy_2<CDTBase>;
using CDT = CGAL::Constrained_triangulation_plus_2<CDTHierarchy>;
};
template<typename VertexInfoType, typename FaceInfoType>
struct TriangulationTraitsTemplate_2_AllowIntersections {
using CDT = typename TriangulationTraitsTemplate_2<
VertexInfoType,
FaceInfoType,
CGAL::Exact_predicates_tag>::CDT;
};
template<int DIM, typename VertexInfoType, typename FaceInfoType>
struct TriangulationTraitsTemplate {};
template<typename VertexInfoType, typename FaceInfoType>
struct TriangulationTraitsTemplate<2, VertexInfoType, FaceInfoType>{
using CDT = typename TriangulationTraitsTemplate_2_AllowIntersections<
VertexInfoType,
FaceInfoType>::CDT;
};
struct VertexInfo
{};
struct FaceInfo
{};
using Triangulation = TriangulationTraitsTemplate<2, VertexInfo, FaceInfo>::CDT;
using Point = Triangulation::Point;
using Edge = Triangulation::Edge;
int main()
{
Triangulation triangulation;
Point p0{ -1.5617169965001162502e-21, -0.0059749999999959748503 };
std::vector<std::array<Point, 2>> as = {
{ p0, Point{ 1.8241074394927896017e-06, -0.0059800116939744598493 } },
{ p0, Point{ 1.8241073772900120186e-06, -0.0059699883060029008269 } },
{ p0, Point{ 5.0116939794452514324e-06, -0.00597682410742579346 } },
{ p0, Point{ 5.0116939818259595034e-06, -0.0059731758925807469998 } }
};
std::vector<std::array<Point, 2>> bs = {
{ Point{ 0.0, -0.0060000000000000001249 }, Point{ 0.0, -0.00596000000000000002 } }
};
for (const auto& a: as) {
auto v1 = triangulation.insert(a[0]);
auto v2 = triangulation.insert(a[1]);
triangulation.insert_constraint(v1, v2);
}
for (const auto& b: bs) {
auto v1 = triangulation.insert(b[0]);
auto v2 = triangulation.insert(b[1]);
triangulation.insert_constraint(v1, v2);
}
return 0;
}