Fix cyclic dependencies

Move shared code to SNC_halfedge_key.h, remove unneeded headers, add a one forward declaration for SNC_io_parser
This commit is contained in:
Giles Bathgate 2023-01-18 19:58:44 +00:00
parent 5f205d3506
commit b5580573d6
6 changed files with 103 additions and 81 deletions

View File

@ -15,8 +15,8 @@
#include <CGAL/license/Nef_3.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/Modifier_base.h>
#include <CGAL/Nef_3/SNC_iteration.h>
namespace CGAL {

View File

@ -24,12 +24,11 @@
#include <CGAL/Nef_S2/Normalizing.h>
#include <CGAL/Nef_3/bounded_side_3.h>
#include <CGAL/Nef_3/Pluecker_line_3.h>
#include <CGAL/Nef_3/SNC_decorator.h>
#include <CGAL/Nef_3/SNC_SM_overlayer.h>
#include <CGAL/Nef_S2/SM_point_locator.h>
#include <CGAL/Nef_3/SNC_halfedge_key.h>
#include <CGAL/Nef_3/SNC_sphere_map.h>
#include <CGAL/Nef_3/SNC_intersection.h>
#include <CGAL/Nef_3/SNC_external_structure.h>
#ifdef SM_VISUALIZOR
#include <CGAL/Nef_3/SNC_SM_visualizor.h>
#endif // SM_VISUALIZOR
@ -41,6 +40,9 @@
namespace CGAL {
template <typename T>
class SNC_io_parser;
template <typename Infi_box, typename Vertex_handle>
struct Frame_point_lt {

View File

@ -25,7 +25,7 @@
#include <CGAL/Nef_3/SNC_point_locator.h>
#include <CGAL/Nef_S2/SM_point_locator.h>
#include <CGAL/Nef_3/SNC_FM_decorator.h>
#include <CGAL/Nef_3/SNC_io_parser.h>
#include <CGAL/Nef_3/SNC_halfedge_key.h>
#include <CGAL/Nef_3/SNC_indexed_items.h>
#include <CGAL/Nef_3/SNC_simplify.h>
#include <map>
@ -40,77 +40,6 @@
namespace CGAL {
struct int_lt {
bool operator()(const int& i1, const int& i2) const { return i1<i2; }
};
template <typename Edge_handle>
struct Halfedge_key_lt4 {
bool operator()(const Edge_handle& e1, const Edge_handle& e2) const {
if(CGAL::sign(e1->point().x()) != 0) {
if(e1->source() != e2->source())
return CGAL::compare_x(e1->source()->point(), e2->source()->point()) < 0;
else
return e1->point().x() < 0;
}
if(CGAL::sign(e1->point().y()) != 0) {
if(e1->source() != e2->source())
return CGAL::compare_y(e1->source()->point(), e2->source()->point()) < 0;
else
return e1->point().y() < 0;
}
if(e1->source() != e2->source())
return CGAL::compare_z(e1->source()->point(), e2->source()->point()) < 0;
return e1->point().z() < 0;
}
};
template <typename Edge_handle>
struct Halfedge_key_lt3 {
bool operator()(const Edge_handle& e1, const Edge_handle& e2) const {
if(e1->source() != e2->source())
return CGAL::lexicographically_xyz_smaller(e1->source()->point(), e2->source()->point());
if(CGAL::sign(e1->point().x()) != 0)
return e1->point().x() < 0;
if(CGAL::sign(e1->point().y()) != 0)
return e1->point().y() < 0;
return e1->point().z() < 0;
}
};
template <typename Point, typename Edge>
struct Halfedge_key {
typedef Halfedge_key<Point,Edge> Self;
Point p; int i; Edge e;
Halfedge_key(Point pi, int ii, Edge ei) :
p(pi), i(ii), e(ei) {}
Halfedge_key(const Self& k) : p(k.p), i(k.i), e(k.e) {}
Self& operator=(const Self& k) { p=k.p; i=k.i; e=k.e; return *this; }
bool operator==(const Self& k) const { return p==k.p && i==k.i; }
bool operator!=(const Self& k) const { return !operator==(k); }
};
template <typename Point, typename Edge, class Decorator>
struct Halfedge_key_lt {
typedef Halfedge_key<Point,Edge> Key;
typedef typename Point::R R;
typedef typename R::Vector_3 Vector;
typedef typename R::Direction_3 Direction;
bool operator()( const Key& k1, const Key& k2) const {
if( k1.e->source() == k2.e->source())
return (k1.i < k2.i);
Direction l(k1.e->vector());
if( k1.i < 0) l = -l;
return (Direction( k2.p - k1.p) == l);
}
};
template <typename Point, typename Edge>
std::ostream& operator<<(std::ostream& os,
const Halfedge_key<Point,Edge>& k )
{ os << k.p << " " << k.i; return os; }
template <typename R>
int sign_of(const CGAL::Plane_3<R>& h)
{ if ( h.c() != 0 ) return CGAL_NTS sign(h.c());

View File

@ -0,0 +1,95 @@
// Copyright (c) 1997-2002 Max-Planck-Institute Saarbruecken (Germany).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Peter Hachenberger <hachenberger@mpi-sb.mpg.de>
#ifndef CGAL_SNC_HALFEDGE_KEY_H
#define CGAL_SNC_HALFEDGE_KEY_H
#include <CGAL/license/Nef_3.h>
#include <CGAL/Kernel/global_functions.h>
namespace CGAL {
struct int_lt {
bool operator()(const int& i1, const int& i2) const { return i1<i2; }
};
template <typename Edge_handle>
struct Halfedge_key_lt4 {
bool operator()(const Edge_handle& e1, const Edge_handle& e2) const {
if(CGAL::sign(e1->point().x()) != 0) {
if(e1->source() != e2->source())
return CGAL::compare_x(e1->source()->point(), e2->source()->point()) < 0;
else
return e1->point().x() < 0;
}
if(CGAL::sign(e1->point().y()) != 0) {
if(e1->source() != e2->source())
return CGAL::compare_y(e1->source()->point(), e2->source()->point()) < 0;
else
return e1->point().y() < 0;
}
if(e1->source() != e2->source())
return CGAL::compare_z(e1->source()->point(), e2->source()->point()) < 0;
return e1->point().z() < 0;
}
};
template <typename Edge_handle>
struct Halfedge_key_lt3 {
bool operator()(const Edge_handle& e1, const Edge_handle& e2) const {
if(e1->source() != e2->source())
return CGAL::lexicographically_xyz_smaller(e1->source()->point(), e2->source()->point());
if(CGAL::sign(e1->point().x()) != 0)
return e1->point().x() < 0;
if(CGAL::sign(e1->point().y()) != 0)
return e1->point().y() < 0;
return e1->point().z() < 0;
}
};
template <typename Point, typename Edge>
struct Halfedge_key {
typedef Halfedge_key<Point,Edge> Self;
Point p; int i; Edge e;
Halfedge_key(Point pi, int ii, Edge ei) :
p(pi), i(ii), e(ei) {}
Halfedge_key(const Self& k) : p(k.p), i(k.i), e(k.e) {}
Self& operator=(const Self& k) { p=k.p; i=k.i; e=k.e; return *this; }
bool operator==(const Self& k) const { return p==k.p && i==k.i; }
bool operator!=(const Self& k) const { return !operator==(k); }
};
template <typename Point, typename Edge, class Decorator>
struct Halfedge_key_lt {
typedef Halfedge_key<Point,Edge> Key;
typedef typename Point::R R;
typedef typename R::Vector_3 Vector;
typedef typename R::Direction_3 Direction;
bool operator()( const Key& k1, const Key& k2) const {
if( k1.e->source() == k2.e->source())
return (k1.i < k2.i);
Direction l(k1.e->vector());
if( k1.i < 0) l = -l;
return (Direction( k2.p - k1.p) == l);
}
};
template <typename Point, typename Edge>
std::ostream& operator<<(std::ostream& os,
const Halfedge_key<Point,Edge>& k )
{ os << k.p << " " << k.i; return os; }
}
#endif //CGAL_SNC_HALFEDGE_KEY_H

View File

@ -24,7 +24,6 @@
#include <CGAL/Nef_S2/SM_decorator.h>
#include <CGAL/Nef_3/SNC_structure.h>
#include <CGAL/Nef_3/SNC_decorator.h>
#include <CGAL/Nef_3/SNC_constructor.h>
#include <CGAL/Nef_2/Object_index.h>
#include <CGAL/Nef_S2/Normalizing.h>
#include <vector>

View File

@ -28,10 +28,7 @@
#include <CGAL/Constrained_triangulation_plus_2.h>
// Nef polyhedra
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/Nef_3/SNC_structure.h>
#include <CGAL/Nef_3/SNC_constructor.h>
#include <CGAL/Nef_3/SNC_point_locator.h>
#include <CGAL/Nef_3/SNC_indexed_items.h>
namespace CGAL {