Improve reader sanity

This commit is contained in:
Mael Rouxel-Labbé 2019-03-15 13:42:20 +01:00
parent e48bed20cc
commit 8648478b9a
10 changed files with 2718 additions and 2675 deletions

View File

@ -1,9 +1,10 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_sphere_2.h>
#include <CGAL/Delaunay_triangulation_sphere_traits_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_sphere_traits_2<K> Traits;
typedef CGAL::Delaunay_triangulation_sphere_2<Traits> DToS2;
@ -15,10 +16,7 @@ int main()
points.push_back(K::Point_3(1,2,1));
points.push_back(K::Point_3(1,-2,1));
Traits traits(K::Point_3(1,1,1));
DToS2 dtos(traits);
dtos.insert(points.begin(), points.end());
}

View File

@ -1,9 +1,12 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_sphere_2.h>
#include <CGAL/Projection_sphere_traits_3.h>
#include <boost/iterator/transform_iterator.hpp>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Projection_sphere_traits_3<K> Projection_traits;
typedef CGAL::Delaunay_triangulation_sphere_2<Projection_traits> Projected_DToS2;
@ -15,18 +18,13 @@ int main()
points.push_back(K::Point_3(1,2,1));
points.push_back(K::Point_3(1,-2,1));
Projection_traits traits(K::Point_3(1,1,1));
Projected_DToS2 dtos(traits);
Projection_traits::Construct_projected_point_3 cst =
traits.construct_projected_point_3_object();
dtos.insert(
boost::make_transform_iterator(points.begin(), cst),
dtos.insert(boost::make_transform_iterator(points.begin(), cst),
boost::make_transform_iterator(points.end(), cst)
);
}

View File

@ -14,7 +14,7 @@
//
// $URL$
// $Id$
//
// SPDX-License-Identifier: GPL-3.0+
//
// Author(s) : Claudia Werner, Mariette Yvinec
@ -26,26 +26,28 @@
namespace CGAL {
template <class Gt, class Fb = Triangulation_face_base_sphere_2<Gt> >
template < class Gt,
class Fb = Triangulation_face_base_sphere_2<Gt> >
class Constrained_triangulation_face_base_sphere_2
: public Fb
{
typedef Fb Base;
typedef typename Fb::Triangulation_data_structure TDS;
public:
typedef Gt Geom_traits;
typedef TDS Triangulation_data_structure;
typedef typename TDS::Vertex_handle Vertex_handle;
typedef typename TDS::Face_handle Face_handle;
template < typename TDS2 >
struct Rebind_TDS {
struct Rebind_TDS
{
typedef typename Fb::template Rebind_TDS<TDS2>::Other Fb2;
typedef Constrained_triangulation_face_base_sphere_2<Gt, Fb2> Other;
};
protected:
bool C[3];
@ -75,7 +77,6 @@ public:
set_constraints(false, false, false);
}
Constrained_triangulation_face_base_sphere_2(Vertex_handle v0,
Vertex_handle v1,
Vertex_handle v2,
@ -90,19 +91,17 @@ public:
set_constraints(c0, c1, c2);
}
bool is_constrained(int i) const ;
void set_constraints(bool c0, bool c1, bool c2) ;
void set_constraint(int i, bool b);
void reorient();
void ccw_permute();
void cw_permute();
};
template <class Gt, class Fb>
inline void
Constrained_triangulation_face_base_sphere_2<Gt,Fb>::
Constrained_triangulation_face_base_sphere_2<Gt, fb>::
set_constraints(bool c0, bool c1, bool c2)
{
C[0] = c0;
@ -112,7 +111,7 @@ set_constraints(bool c0, bool c1, bool c2)
template <class Gt, class Fb>
inline void
Constrained_triangulation_face_base_sphere_2<Gt,Fb>::
Constrained_triangulation_face_base_sphere_2<Gt, fb>::
set_constraint(int i, bool b)
{
CGAL_triangulation_precondition(i == 0 || i == 1 || i == 2);
@ -121,7 +120,7 @@ set_constraint(int i, bool b)
template <class Gt, class Fb>
inline bool
Constrained_triangulation_face_base_sphere_2<Gt,Fb>::
Constrained_triangulation_face_base_sphere_2<Gt, fb>::
is_constrained(int i) const
{
return(C[i]);
@ -129,29 +128,29 @@ is_constrained(int i) const
template <class Gt, class Fb>
inline void
Constrained_triangulation_face_base_sphere_2<Gt,Fb>::
Constrained_triangulation_face_base_sphere_2<Gt, fb>::
reorient()
{
Base::reorient();
set_constraints(C[1],C[0],C[2]);
set_constraints(C[1], c[0], c[2]);
}
template <class Gt, class Fb>
inline void
Constrained_triangulation_face_base_sphere_2<Gt,Fb>::
Constrained_triangulation_face_base_sphere_2<Gt, fb>::
ccw_permute()
{
Base::ccw_permute();
set_constraints(C[2],C[0],C[1]);
set_constraints(C[2], c[0], c[1]);
}
template <class Gt, class Fb>
inline void
Constrained_triangulation_face_base_sphere_2<Gt,Fb>::
Constrained_triangulation_face_base_sphere_2<Gt, fb>::
cw_permute()
{
Base::cw_permute();
set_constraints(C[1],C[2],C[0]);
set_constraints(C[1], c[2], c[0]);
}
} // namespace CGAL

View File

@ -1,3 +1,23 @@
// Copyright (c) 1997, 2012, 2019 INRIA Sophia-Antipolis (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 Licenxse, 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.
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
// Author(s) : Mariette Yvinec, Claudia Werner
#ifndef CGAL_Delaunay_triangulation_sphere_2_H
#define CGAL_Delaunay_triangulation_sphere_2_H
@ -6,14 +26,17 @@
#include <CGAL/Triangulation_sphere_2.h>
#include <CGAL/Triangulation_face_base_sphere_2.h>
#include <CGAL/Triangulation_vertex_base_2.h>
#include <CGAL/enum.h>
#include <CGAL/utility.h>
#include <fstream>
#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
namespace CGAL {
template < class Gt,
class Tds = Triangulation_data_structure_2 <
Triangulation_vertex_base_2<Gt>,
@ -21,25 +44,28 @@ template < class Gt,
class Delaunay_triangulation_sphere_2
: public Triangulation_sphere_2<Gt, Tds>
{
typedef Delaunay_triangulation_sphere_2<Gt, Tds> Self;
typedef Triangulation_sphere_2<Gt, Tds> Base;
public:
typedef Tds Triangulation_data_structure;
typedef Gt Geom_traits;
typedef typename Gt::Point_2 Point;
typedef typename Gt::Segment_3 Segment;
typedef typename Base::size_type size_type;
typedef typename Base::Face_handle Face_handle;
typedef typename Base::Vertex_handle Vertex_handle;
typedef typename Base::Vertex Vertex;
typedef typename Base::Vertex_handle Vertex_handle;
typedef typename Base::Edge Edge;
typedef typename Base::Face_handle Face_handle;
typedef typename Base::Locate_type Locate_type;
typedef typename Base::Face_circulator Face_circulator;
typedef typename Base::Edge_circulator Edge_circulator;
typedef typename Base::Vertex_circulator Vertex_circulator;
typedef typename Base::Edge_circulator Edge_circulator;
typedef typename Base::Face_circulator Face_circulator;
typedef typename Base::All_vertices_iterator All_vertices_iterator;
typedef typename Base::All_edges_iterator All_edges_iterator;
typedef typename Base::All_faces_iterator All_faces_iterator;
@ -47,7 +73,6 @@ public:
typedef typename Base::Solid_edges_iterator Solid_edges_iterator;
typedef typename Base::Contour_edges_iterator Contour_edges_iterator;
#ifndef CGAL_CFG_USING_BASE_MEMBER_BUG_2
using Base::cw;
using Base::ccw;
@ -84,18 +109,18 @@ public:
using Base::coplanar_orientation;
using Base::set_radius;
using Base::circumcenter;
#endif
//class for sorting points lexicographically.
//This sorting is used for the perturbation in power_test
class Perturbation_order {
// class to sort points lexicographically.
// This sorting is used for the symbolic perturbation in power_test
class Perturbation_order
{
const Self *t;
public:
Perturbation_order(const Self *tr)
: t(tr) {}
Perturbation_order(const Self *tr) : t(tr) { }
bool operator()(const Point *p, const Point *q) const {
bool operator()(const Point *p, const Point *q) const
{
return t->compare_xyz(*p, *q) == SMALLER;
}
};
@ -106,17 +131,18 @@ public:
: Base(Gt(gt))
{ }
// CHECK
bool is_valid(bool verbose = false, int level = 0) const;
bool is_valid_face(Face_handle fh, bool verbose = false, int level = 0) const;
bool is_valid_vertex(Vertex_handle fh, bool verbose = false, int level = 0) const;
bool is_plane() const;
// checks whether neighboring faces are linked correctly to each other.
void check_neighboring()
{
All_faces_iterator eit;
if(dimension()==1){
if(dimension() == 1)
{
for(eit=all_faces_begin(); eit!=all_faces_end(); ++eit)
{
Face_handle f1 = eit->neighbor(0);
@ -124,7 +150,6 @@ public:
CGAL_triangulation_assertion(f1->has_neighbor(eit));
CGAL_triangulation_assertion(f2->has_neighbor(eit));
}
}
for(eit=all_faces_begin();eit!=all_faces_end();++eit)
@ -136,10 +161,8 @@ public:
CGAL_triangulation_assertion(f2->has_neighbor(eit));
CGAL_triangulation_assertion(f3->has_neighbor(eit));
}
}
//INSERTION
Vertex_handle insert(const Point& p, Locate_type lt, Face_handle loc, int li);
Vertex_handle insert(const Point& p, Face_handle f = Face_handle());
@ -160,7 +183,6 @@ public:
bool test_dim_up(const Point& p) const;
void fill_hole_regular(std::list<Edge> & hole);
Oriented_side power_test(const Point& p, const Point& q, const Point& r, const Point& s, bool perturb = false) const;
Oriented_side power_test(const Point& p, const Point& q, const Point& r) const;
Oriented_side power_test(const Point& p, const Point& r) const;
@ -173,55 +195,55 @@ public:
Object dual(const Edge_circulator& ec) const;
Object dual(const All_edges_iterator& ei) const;
// TEMPLATE MEMBERS
//----------------------------------------------------------------------HOLE APPROACH
//------------------------ HOLE APPROACH
template <class Stream>
Stream& write_vertices(Stream& out, std::vector<Vertex_handle> &t)
{
for(typename std::vector<Vertex_handle>::iterator it=t.begin(); it!=t.end(); ++it)
{if((*it)->face()==Face_handle()){
{
if((*it)->face() == Face_handle())
{
Point p=(*it)->point();
out << p.x() << " "
<< p.y() << " "
<< p.z() << std::endl;
out << p.x() << " " << p.y() << " " << p.z() << std::endl;
}
}
return out;
}
template <class Stream>
Stream& write_triangulation_to_off_2(Stream& out, Stream& out2)
{
// Points of triangulation
for (All_faces_iterator it = this->_tds.face_iterator_base_begin(); it !=all_faces_end(); it++) {
if(!it->is_ghost()){//assert(orientation(it)==POSITIVE);
for (int i=0 ; i<3 ; i++) {
for(All_faces_iterator it=this->_tds.face_iterator_base_begin(); it!=all_faces_end(); ++it)
{
if(!it->is_ghost())
{
// assert(orientation(it) == POSITIVE);
for(int i=0; i<3; ++i)
{
if(it->vertex(i)!=Vertex_handle())
{
Point p = it->vertex(i)->point();
out << p.x() << " "
<< p.y() << " "
<< p.z() << std::endl;
out << p.x() << " " << p.y() << " " << p.z() << std::endl;
}
}
}
else{
for (int i=0 ; i<3 ; i++){
else
{
for(int i=0; i<3; ++i)
{
if(it->vertex(i)!=Vertex_handle())
{
Point p = it->vertex(i)->point();
out2 << p.x() << " "
<< p.y() << " "
<< p.z() << std::endl;
out2 << p.x() << " " << p.y() << " " << p.z() << std::endl;
}
}
}
}
return out;
}
@ -231,12 +253,12 @@ Stream &write_triangulation_to_off(Stream &out)
std::vector<Face_handle> faces;
// Points of triangulation
for (All_faces_iterator it =all_faces_begin(); it !=all_faces_end(); it++) {
for (int i=0 ; i<3 ; i++) {
for(All_faces_iterator it=all_faces_begin(); it!=all_faces_end(); ++it)
{
for(int i=0; i<3; ++i)
{
Point p = it->vertex(i)->point();
out << p.x() << " "
<< p.y() << " "
<< p.z() << std::endl;
out << p.x() << " " << p.y() << " " << p.z() << std::endl;
}
}
@ -246,31 +268,25 @@ Stream &write_triangulation_to_off(Stream &out)
template <class Stream >
Stream& write_face_to_off(Stream& out, Face_handle f)
{
for (int i=0 ; i<3 ; i++) {
for(int i=0; i<3; ++i)
{
Point p = f->vertex(i)->point();
out << p.x() << " "
<< p.y() << " "
<< p.z() << std::endl;
out << p.x() << " " << p.y() << " " << p.z() << std::endl;
}
return out;
}
template <class Stream, class FaceIt>
Stream& write_faces_to_off(Stream& out, FaceIt face_begin, FaceIt face_end)
{
FaceIt fit = face_begin;
for(; fit!=face_end; ++fit)
{
for (int i=0 ; i<3 ; i++) {
for(int i=0; i<3; ++i)
{
Point p = (*fit)->vertex(i)->point();
out << p.x() << " "
<< p.y() << " "
<< p.z() << std::endl;
out << p.x() << " " << p.y() << " " << p.z() << std::endl;
}
}
@ -280,7 +296,6 @@ Stream &write_faces_to_off(Stream &out,FaceIt face_begin, FaceIt face_end)
template <class Stream, class FaceIt>
Stream& write_edges_to_off(Stream& out, FaceIt face_begin, FaceIt face_end)
{
FaceIt fit=face_begin;
for(; fit!=face_end; ++fit)
{
@ -290,17 +305,13 @@ Stream &write_edges_to_off(Stream &out,FaceIt face_begin, FaceIt face_end)
Point p = f->vertex(cw(i))->point();
Point q = f->vertex(ccw(i))->point();
out << p.x() << " "
<< p.y() << " "
<< p.z() << std::endl;
out << q.x() << " "
<< q.y() << " "
<< q.z() << std::endl;
out << p.x() << " " << p.y() << " " << p.z() << std::endl;
out << q.x() << " " << q.y() << " " << q.z() << std::endl;
}
return out;
}
//insert points in a given range using spacial sorting
template < class InputIterator >
int insert(InputIterator first, InputIterator last)
@ -313,7 +324,8 @@ int insert(InputIterator first, InputIterator last)
Face_handle hint;
Vertex_handle v;
for (typename std::vector<Point>::const_iterator p = points.begin(),end = points.end(); p != end; ++p){
for(typename std::vector<Point>::const_iterator p=points.begin(), end=points.end(); p != end; ++p)
{
v = insert(*p, hint);
if(v != Vertex_handle())//could happen if the point is not on the sphere
hint = v->face();
@ -324,7 +336,9 @@ int insert(InputIterator first, InputIterator last)
template <class OutputItFaces, class OutputItBoundaryEdges>
std::pair<OutputItFaces,OutputItBoundaryEdges>
get_conflicts_and_boundary(const Point &p, OutputItFaces fit, OutputItBoundaryEdges eit,
get_conflicts_and_boundary(const Point& p,
OutputItFaces fit,
OutputItBoundaryEdges eit,
Face_handle fh) const
{
CGAL_triangulation_precondition(dimension() == 2);
@ -332,8 +346,8 @@ get_conflicts_and_boundary(const Point &p, OutputItFaces fit, OutputItBoundaryE
*fit++ = fh; //put fh in OutputItFaces
fh->set_in_conflict_flag(1);
std::pair<OutputItFaces,OutputItBoundaryEdges>
pit = std::make_pair(fit,eit);
std::pair<OutputItFaces,OutputItBoundaryEdges> pit = std::make_pair(fit, eit);
pit = propagate_conflicts(p, fh,0, pit);
pit = propagate_conflicts(p, fh,1, pit);
pit = propagate_conflicts(p, fh,2, pit);
@ -341,7 +355,6 @@ get_conflicts_and_boundary(const Point &p, OutputItFaces fit, OutputItBoundaryE
return std::make_pair(fit, eit);
}
private:
template <class OutputItFaces, class OutputItBoundaryEdges>
std::pair<OutputItFaces, OutputItBoundaryEdges>
@ -351,9 +364,13 @@ propagate_conflicts (const Point &p, Face_handle fh, int i,
Face_handle fn = fh->neighbor(i);
if(fn->get_in_conflict_flag() == 1)
return pit;
if(!test_conflict(p, fn))
{
*(pit.second)++ = Edge(fn, fn->index(fh));
else {
}
else
{
*(pit.first)++ = fn;
fn->set_in_conflict_flag(1);
int j = fn->index(fh);
@ -362,8 +379,6 @@ propagate_conflicts (const Point &p, Face_handle fh, int i,
}
return pit;
}
};
//------------power-test
@ -387,6 +402,7 @@ power_test(const Face_handle& f, int i, const Point &p) const
return power_test(f->vertex(ccw(i))->point(), f->vertex(cw(i))->point(), p);
}
// computes the power-test of 4 points. perturb defines whether a symbolic perturbation
// is used (by default : perturb == false)
// in the perturbation the smalest vertex is in conflict with the others
@ -399,14 +415,15 @@ power_test(const Point &p0, const Point &p1, const Point &p2, const Point &p, bo
Oriented_side os = geom_traits().power_test_2_object()(p0, p1, p2, p);
if(os != ON_ORIENTED_BOUNDARY || !perturb)
return os;
// We are now in a degenerate case => we do a symbolic perturbation.
// We sort the points lexicographically.
const Point * points[3] = { &p0, &p1, &p2 };
std::sort(points, points+3, Perturbation_order(this));
if(points[0] == &p0){
if(points[0] == &p0)
{
if(compare_xyz(p, p0) == SMALLER)
return ON_POSITIVE_SIDE;
if(coplanar_orientation(p0, p1, p, p2) == ON_NEGATIVE_SIDE)
@ -417,7 +434,8 @@ power_test(const Point &p0, const Point &p1, const Point &p2, const Point &p, bo
return ON_POSITIVE_SIDE;
}
if(points[0] == &p1){
if(points[0] == &p1)
{
if(compare_xyz(p, p1) == SMALLER)
return ON_POSITIVE_SIDE;
if(coplanar_orientation(p1, p0, p, p2) == ON_NEGATIVE_SIDE)
@ -428,7 +446,8 @@ power_test(const Point &p0, const Point &p1, const Point &p2, const Point &p, bo
return ON_POSITIVE_SIDE;
}
if(points[0] == &p2){
if(points[0] == &p2)
{
if(compare_xyz(p, p2) == SMALLER)
return ON_POSITIVE_SIDE;
if(coplanar_orientation(p2, p1, p, p0) == ON_NEGATIVE_SIDE)
@ -441,10 +460,8 @@ power_test(const Point &p0, const Point &p1, const Point &p2, const Point &p, bo
CGAL_assertion(false);
return ON_NEGATIVE_SIDE;
}
template < class Gt, class Tds >
inline
Oriented_side
@ -454,31 +471,41 @@ power_test(const Point &p, const Point &q, const Point &r) const
if(number_of_vertices() == 2)
if(orientation_1(p, q) == COLLINEAR)
return ON_POSITIVE_SIDE;
return geom_traits().power_test_2_object()(p, q, r);
}
//----------------------------------------------------------------------CHECK---------------------------------------------------------------//
//checks whether a given triangulation is plane (all points are coplanar)
template <class Gt, class Tds>
bool
Delaunay_triangulation_sphere_2<Gt, Tds>::
is_plane()const{
is_plane() const
{
bool plane = true;
if(dimension() == 2)
return false;
if(number_of_vertices() > 3){
All_vertices_iterator it1 = vertices_begin(),
it2(it1), it3(it1), it4(it1);
if(number_of_vertices() > 3)
{
All_vertices_iterator it1 = vertices_begin(), it2(it1), it3(it1), it4(it1);
++it2;
++it3; ++it3;
++it4; ++it4; ++it4;
while( it4 != vertices_end()) {
while(it4 != vertices_end())
{
Orientation s = power_test(it1->point(), it2->point(), it3->point(), it4->point());
plane = plane && s == ON_ORIENTED_BOUNDARY;
++it1 ; ++it2; ++it3;++it4;
++it1;
++it2;
++it3;
++it4;
if(!plane)
return plane;
}return true;
}
return true;
}
if(number_of_vertices() == 3)
@ -494,9 +521,11 @@ is_valid(bool verbose, int level ) const
{
bool result = true;
if ( !this-> _tds.is_valid(verbose,level) ) {
if(!this-> _tds.is_valid(verbose, level))
{
if(verbose)
std::cerr << "invalid data structure" << std::endl;
CGAL_triangulation_assertion(false);
return false;
}
@ -507,15 +536,16 @@ is_valid(bool verbose, int level ) const
for(All_vertices_iterator vit=vertices_begin(); vit!=vertices_end(); ++vit)
is_valid_vertex(vit, verbose, level);
switch(dimension()) {
switch(dimension())
{
case 0 :
break;
case 1:
CGAL_triangulation_assertion(this->is_plane());
break;
case 2 :
for(All_faces_iterator it=all_faces_begin(); it!=all_faces_end(); it++) {
for(All_faces_iterator it=all_faces_begin(); it!=all_faces_end(); ++it)
{
Orientation s = orientation(it->vertex(0)->point(), it->vertex(1)->point(), it->vertex(2)->point());
result = result && (s != NEGATIVE || it->is_ghost());
CGAL_triangulation_assertion(result);
@ -534,24 +564,28 @@ is_valid(bool verbose, int level ) const
return result;
}
template < class Gt, class Tds >
bool
Delaunay_triangulation_sphere_2<Gt, Tds>::
is_valid_vertex(Vertex_handle vh, bool verbose, int level) const
{
bool result = vh->face()->has_vertex(vh);
if ( !result ) {
if(verbose) {
if(!result)
{
if(verbose)
{
std::cerr << " from is_valid_vertex " << std::endl;
std::cerr << "normal vertex " << &(*vh) << std::endl;
std::cerr << vh->point() << " " << std::endl;
std::cerr << "vh_>face " << &*(vh->face()) << " " << std::endl;
show_face(vh->face());
}
CGAL_triangulation_assertion(false);
return false;
}
return true;
}
@ -561,22 +595,27 @@ Delaunay_triangulation_sphere_2<Gt,Tds>::
is_valid_face(Face_handle fh, bool verbose, int level) const
{
bool result = fh->get_in_conflict_flag() == 0;
for (int i = 0; i<+2; i++) {
for(int i=0; i<+2; ++i)
{
Orientation test = power_test(fh, fh->vertex(i)->point());
result = result && test == ON_ORIENTED_BOUNDARY;
CGAL_triangulation_assertion(result);
}
if(!result)
if (verbose){
{
if(verbose)
{
std::cerr << " from is_valid_face " << std::endl;
std::cerr << " face " << std::endl;
show_face(fh);
}
}
CGAL_triangulation_assertion(result);
return result;
}
// tests whether there is a conflict between p and the face fh
template < class Gt, class Tds >
inline bool
@ -586,9 +625,7 @@ test_conflict(const Point &p, Face_handle fh) const
return(power_test(fh, p, true) != ON_NEGATIVE_SIDE);
}
//----------------------------------------------------------------------INSERTION-------------------------------------------------------------//
// ------------------------ INSERTION --------------------------------//
template < class Gt, class Tds >
typename Delaunay_triangulation_sphere_2<Gt, Tds>::Vertex_handle
Delaunay_triangulation_sphere_2<Gt, Tds>::
@ -597,17 +634,22 @@ insert(const Point &p, Face_handle start)
Locate_type lt;
int li;
Face_handle loc = Base::locate(p, lt, li, start);
switch (lt){
switch (lt)
{
case NOT_ON_SPHERE:
return Vertex_handle();
case TOO_CLOSE:{
case TOO_CLOSE:
{
if(dimension() == 2)
return loc->vertex(li);
return Vertex_handle();
}
case VERTEX:{
case VERTEX:
{
if(number_of_vertices() == 1)
return vertices_begin();
return (loc->vertex(li));
}
default: //point can be inserted
@ -621,11 +663,9 @@ typename Delaunay_triangulation_sphere_2<Gt,Tds>::Vertex_handle
Delaunay_triangulation_sphere_2<Gt, Tds>::
insert_cocircular(const Point& p, Locate_type lt, Face_handle loc)
{
CGAL_triangulation_precondition(!test_dim_up(p));
CGAL_triangulation_precondition(dimension() == 1);
Vertex_handle v0 = loc->vertex(0);
Vertex_handle v1 = loc->vertex(1);
Vertex_handle v = this->_tds.create_vertex();
@ -642,14 +682,12 @@ insert_cocircular(const Point &p, Locate_type lt, Face_handle loc)
this->_tds.set_adjacency(f1,1, loc->neighbor(1),0);
this->_tds.set_adjacency(f2,0, loc->neighbor(0),1);
this->delete_face(loc);
update_ghost_faces(v);
return v;
}
template <class Gt, class Tds >
typename Triangulation_sphere_2<Gt, Tds>::Vertex_handle
Delaunay_triangulation_sphere_2<Gt, Tds>::
@ -672,7 +710,6 @@ insert_second(const Point& p)
return v;
}
// inserts a point which location is known. Calls the corresponding insert-function
// e.g. insert_first
template < class Gt, class Tds >
@ -681,15 +718,18 @@ Delaunay_triangulation_sphere_2<Gt,Tds>::
insert(const Point& p, Locate_type lt, Face_handle loc, int li)
{
Vertex_handle v;
switch (dimension()){
switch (dimension())
{
case -2 :
return insert_first(p);
case -1:
return insert_second(p);
case 0:
return insert_outside_affine_hull_regular(p);
case 1:{
if(test_dim_up(p)){
case 1:
{
if(test_dim_up(p))
{
Face_handle f = all_edges_begin()->first;
Vertex_handle v1 = f->vertex(0);
Vertex_handle v2 = f->vertex(1);
@ -697,9 +737,12 @@ insert(const Point &p, Locate_type lt, Face_handle loc, int li)
return insert_outside_affine_hull_regular(p);
}
else
{
return insert_cocircular(p, lt, loc);
}
case 2:{
}
case 2:
{
std::vector<Face_handle> faces;
std::vector<Edge> edges;
faces.reserve(32);
@ -716,24 +759,26 @@ insert(const Point &p, Locate_type lt, Face_handle loc, int li)
return v;
}
}
CGAL_assertion(false);
return v;
}
//inserts a new point which lies outside the affine hull of the other points
template <class Gt, class Tds >
typename Triangulation_sphere_2<Gt, Tds>::Vertex_handle
Delaunay_triangulation_sphere_2<Gt, Tds>::
insert_outside_affine_hull_regular(const Point& p)
{
if(dimension()==0){
if(dimension() == 0)
{
Vertex_handle v = vertices_begin();
Vertex_handle u = v->face()->neighbor(0)->vertex(0);
Vertex_handle nv;
//orientation is given by the 2 first points
if( this->collinear_between(v->point(),u->point(),p) || orientation(u->point(),v->point(),p) == LEFT_TURN )
if(this->collinear_between(v->point(), u->point(), p) ||
orientation(u->point(), v->point(), p) == LEFT_TURN)
nv = Base::tds().insert_dim_up(v, false);
else
nv = Base::tds().insert_dim_up(v, true);
@ -747,8 +792,8 @@ insert_outside_affine_hull_regular(const Point& p)
update_ghost_faces(nv);
return nv;
}
else{ //dimension 1
else // dimension 1
{
bool conform = false;
Face_handle f = (all_edges_begin())->first;
Face_handle fn = f->neighbor(0);
@ -759,18 +804,17 @@ insert_outside_affine_hull_regular(const Point& p)
CGAL_triangulation_assertion(orientation(p0, p1, p2)!=NEGATIVE);
Orientation orient2 = power_test(p0, p1, p2, p);
if(orient2 == POSITIVE)
conform = true;
// find smalest vertex this step garanties a unique triangulation
Vertex_handle w=vertices_begin();
All_vertices_iterator vi;
for( vi = vertices_begin(); vi != vertices_end(); vi++){
if(compare_xyz(vi->point(), w->point())==SMALLER){
for(vi=vertices_begin(); vi!=vertices_end(); ++vi)
{
if(compare_xyz(vi->point(), w->point()) == SMALLER)
w = vi;
}
}
Vertex_handle v = this->_tds.insert_dim_up(w, conform);
v->set_point(p);
@ -781,12 +825,11 @@ insert_outside_affine_hull_regular(const Point& p)
}
}
/*method to mark faces incident to v as ghost-faces or solid-faces.
bool first defines whether dimension of the triangulation increased
from one to two by inserting v
If first == true all faces are updated.
/*
* method to mark faces incident to v as ghost-faces or solid-faces.
* bool first defines whether dimension of the triangulation increased
* from one to two by inserting v
* If first == true all faces are updated.
*/
template < class Gt, class Tds >
bool
@ -797,13 +840,16 @@ update_ghost_faces(Vertex_handle v, bool first)
return false;
bool neg_found = false;
if(dimension()==1){
if(dimension() == 1)
{
All_edges_iterator eit = all_edges_begin();
for (; eit!=all_edges_end(); eit++){
for(; eit!=all_edges_end(); ++eit)
{
Face_handle f=eit->first;
Face_handle fn=f->neighbor(0);
Point q=fn->vertex(1)->point();
if(this->collinear_between(f->vertex(0)->point(),f->vertex(1)->point(),q)){
if(this->collinear_between(f->vertex(0)->point(), f->vertex(1)->point(), q))
{
f->ghost() = true;
neg_found = true;
}
@ -811,37 +857,46 @@ update_ghost_faces(Vertex_handle v, bool first)
f->ghost()=false;
}
}
else{//dimension==2
if (first){ //first time dimension 2
else // dimension==2
{
if(first) // first time dimension 2
{
All_faces_iterator fi = all_faces_begin();
for(;fi!=all_faces_end();fi++){
if(orientation(fi)!=POSITIVE){
for(; fi!=all_faces_end(); fi++)
{
if(orientation(fi) != POSITIVE)
{
fi->ghost() = true;
neg_found = true;
this->_ghost = fi;
}
else
{
fi->ghost() = false;
}
}
else { //not first
}
else // not first
{
Face_circulator fc = this->incident_faces(v, v->face());
Face_circulator done(fc);
do{
if(orientation(fc)!=POSITIVE){
do
{
if(orientation(fc) != POSITIVE)
{
fc->ghost() = true;
neg_found = true;
this->_ghost = fc;
}
else
{
fc->ghost() = false;
}
} while(++fc != done);
}
}
return neg_found;
return neg_found;
}
//-------------------------------------------------------------------------------REMOVAL----------------------------------------------------//
@ -850,13 +905,12 @@ void
Delaunay_triangulation_sphere_2<Gt, Tds>::
remove_degree_3(Vertex_handle v, Face_handle f)
{
if (f == Face_handle()) f=v->face();
if(f == Face_handle())
f = v->face();
this->_tds.remove_degree_3(v, f);
}
template < class Gt, class Tds >
void
Delaunay_triangulation_sphere_2<Gt, Tds>::
@ -865,17 +919,12 @@ remove(Vertex_handle v )
CGAL_triangulation_precondition(v != Vertex_handle());
if(number_of_vertices()<=3)
this->_tds.remove_dim_down(v);
else if(dimension() == 2)
remove_2D (v);
else
remove_1D(v);
}
template <class Gt, class Tds >
void
Delaunay_triangulation_sphere_2<Gt, Tds>::
@ -885,9 +934,6 @@ remove_1D(Vertex_handle v)
update_ghost_faces();
}
template < class Gt, class Tds >
void
Delaunay_triangulation_sphere_2<Gt, Tds>::
@ -895,20 +941,19 @@ remove_2D(Vertex_handle v)
{
CGAL_triangulation_precondition(dimension() == 2);
if (test_dim_down(v)) { //resulting triangulation has dim 1
if(test_dim_down(v)) // resulting triangulation has dim 1
{
this->_tds.remove_dim_down(v);
update_ghost_faces(); //1d triangulation, no vertex needed to update ghost-faces
}
else {
else
{
std::list<Edge> hole;
this->make_hole(v, hole);
fill_hole_regular(hole);
}
return;
}
// tests whether the dimension will decrease when removing v from the triangulation.
template <class Gt, class Tds >
bool
@ -917,25 +962,25 @@ test_dim_down(Vertex_handle v)
{
CGAL_triangulation_precondition(dimension() == 2);
bool dim1 = true;
if(number_of_vertices()==4){
if(number_of_vertices() == 4)
return dim1;
}
std::vector<Point> points;
All_vertices_iterator it = vertices_begin();
for(; it!=vertices_end();it ++)
for(; it!=vertices_end(); ++it)
if(it != v)
points.push_back(it->point());
for(int i=0; i<(int)points.size()-4; i++){
for(int i=0; i<(int)points.size()-4; ++i)
{
Orientation s = power_test(points.at(i), points.at(i+1), points.at(i+2), points.at(i+3));
dim1 = dim1 && s == ON_ORIENTED_BOUNDARY;
if(!dim1)
return dim1;
}return true;
}
return true;
}
// tests whether the dimension will increase when adding p to the triangulation.
template <class Gt, class Tds >
@ -951,7 +996,6 @@ test_dim_up(const Point &p) const
v1->point();
return (power_test(v1->point(), v2->point(), v3->point(), p) != ON_ORIENTED_BOUNDARY);
}
//fill the hole in a triangulation after vertex removal.
@ -981,7 +1025,7 @@ fill_hole_regular(std::list<Edge> & first_hole)
{
Face_handle newf = create_face();
hit = hole.begin();
for(int j=0; j<3; j++)
for(int j=0; j<3; ++j)
{
ff = (*hit).first;
ii = (*hit).second;
@ -990,7 +1034,9 @@ fill_hole_regular(std::list<Edge> & first_hole)
newf->set_neighbor(j, ff);
newf->set_vertex(newf->ccw(j), ff->vertex(ff->cw(ii)));
}
if(orientation(newf) != POSITIVE){
if(orientation(newf) != POSITIVE)
{
this->_ghost = newf;
newf->ghost() = true;
}
@ -1023,13 +1069,15 @@ fill_hole_regular(std::list<Edge> & first_hole)
// if tested vertex is c with respect to the vertex opposite
// to NULL neighbor,
// stop at the before last face;
hdone--;
--hdone;
while(hit != hdone)
{
fn = (*hit).first;
in = (*hit).second;
vv = fn->vertex(ccw(in));
p = vv->point();
if(/*orientation(p0, p1, p) == COUNTERCLOCKWISE*/ 1)
{
if(v2==Vertex_handle())
@ -1038,8 +1086,7 @@ fill_hole_regular(std::list<Edge> & first_hole)
p2=p;
cut_after=hit;
}
else if (power_test(p0,p1,p2,p) ==
ON_POSITIVE_SIDE)
else if(power_test(p0, p1, p2, p) == ON_POSITIVE_SIDE)
{
v2 = vv;
p2 = p;
@ -1054,10 +1101,12 @@ fill_hole_regular(std::list<Edge> & first_hole)
Face_handle newf = create_face(v0, v1, v2);
newf->set_neighbor(2, ff);
ff->set_neighbor(ii, newf);
if(orientation(newf) != POSITIVE){
if(orientation(newf) != POSITIVE)
{
this->_ghost = newf;
newf->ghost() = true;
}
//update the hole and push back in the Hole_List stack
// if v2 belongs to the neighbor following or preceding *f
// the hole remain a single hole
@ -1125,8 +1174,9 @@ dual(const Edge &e) const
{
CGAL_triangulation_precondition(this->_tds.is_edge(e.first, e.second));
CGAL_triangulation_precondition(dimension() == 2);
Segment s = this->geom_traits().construct_segment_2_object()
(dual(e.first),dual(e.first->neighbor(e.second)));
Segment s = this->geom_traits().construct_segment_2_object()(
dual(e.first), dual(e.first->neighbor(e.second)));
return make_object(s);
}

View File

@ -1,12 +1,27 @@
// Author(s) :
// Copyright (c) 1997, 2012, 2019 INRIA Sophia-Antipolis (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 Licenxse, 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.
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
// Author(s) : Mariette Yvinec, Claudia Werner
#ifndef CGAL_DELAUNAY_TRIANGULATION_SPHERE_FILTERED_TRAITS_2_H
#define CGAL_DELAUNAY_TRIANGULATION_SPHERE_FILTERED_TRAITS_2_H
#include <CGAL/basic.h>
#include <CGAL/Delaunay_triangulation_sphere_traits_2.h>
#include <CGAL/Filtered_predicate.h>
//#include <CGAL/static_in_cone_ntC3.h>
namespace CGAL {
@ -34,11 +49,8 @@ struct Delaunay_weighted_converter_2
return Target_wp(Converter::operator()(wp.point()),
Converter::operator()(wp.weight()));
}*/
Target_wp
operator()(const Source_wp &wp) const
{
return Converter::operator()(wp);
}
Target_wp operator()(const Source_wp &wp) cons { return Converter::operator()(wp); }
};
/*

View File

@ -1,24 +1,27 @@
// Copyright (c) 1997, 2012, 2019 INRIA Sophia-Antipolis (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 Licenxse, 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.
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
// Author(s) : Mariette Yvinec, Claudia Werner
#ifndef CGAL_DELAUNAY_TRIANGULATION_SPHERE_TRAITS_2_H
#define CGAL_DELAUNAY_TRIANGULATION_SPHERE_TRAITS_2_H
#include <CGAL/number_utils_classes.h>
#include <CGAL/triangulation_assertions.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/Line_2.h>
#include <CGAL/Ray_2.h>
#include <CGAL/Point_2.h>
#include <CGAL/Segment_2.h>
#include <CGAL/Triangle_2.h>
#include <CGAL/Line_2.h>
#include <CGAL/Ray_2.h>
#include <CGAL/predicates_on_points_2.h>
#include <CGAL/basic_constructions_2.h>
#include <CGAL/distance_predicates_2.h>
#include <CGAL/triangulation_assertions.h>
#include <CGAL/Segment_2_Segment_2_intersection.h>
#include <CGAL/enum.h>
namespace CGAL {
@ -30,15 +33,15 @@ class Power_test_2
typedef typename K::Oriented_side Oriented_side;
typedef typename K::Comparison_result Comparison_result;
Power_test_2(const Point_2& sphere);
Oriented_side operator()(const Point_2& p,
const Point_2& q,
const Point_2& r,
const Point_2& s) const
{ return orientation(p,q,r,s); }
{
return orientation(p, q, r, s);
}
Oriented_side operator()(const Point_2& p,
const Point_2& q,
@ -47,21 +50,21 @@ class Power_test_2
return -coplanar_orientation(p, q,_sphere, r);
}
Oriented_side operator()(const Point_2& p,
const Point_2& q) const
{
Comparison_result pq = compare_xyz(p, q);
if(pq==EQUAL){
if(pq == EQUAL)
return ON_ORIENTED_BOUNDARY;
}
Comparison_result sq = compare_xyz(_sphere, q);
if(pq==sq){
if(pq == sq)
return ON_POSITIVE_SIDE;
}
return ON_NEGATIVE_SIDE;
}
public:
typedef Oriented_side result_type;
@ -75,31 +78,33 @@ Power_test_2(const Point_2& sphere)
: _sphere(sphere)
{ }
template < typename K >
class Orientation_sphere_1
{
public:
typedef typename K::Point_2 Point_2;
typedef typename K::Comparison_result Comparison_result;
typedef Comparison_result result_type;
Orientation_sphere_1(const Point_2& sphere);
Comparison_result operator()(const Point_2& p, const Point_2& q) const
{ return coplanar_orientation(_sphere,p,q);}
{
return coplanar_orientation(_sphere, p, q);
}
Comparison_result operator()(const Point_2& p, const Point_2& q, const Point_2& r) const
{ return coplanar_orientation(p,q,r,_sphere); }
{
return coplanar_orientation(p, q, r, _sphere);
}
Comparison_result operator()(const Point_2& p, const Point_2& q, const Point_2& r, const Point_2& s) const
{ return coplanar_orientation(p,q,r,s);}
{
return coplanar_orientation(p, q, r, s);
}
protected :
Point_2 _sphere;
public:
typedef Comparison_result result_type;
};
template < typename K >
@ -108,8 +113,6 @@ Orientation_sphere_1(const Point_2& sphere)
: _sphere(sphere)
{ }
template < typename K >
class Orientation_sphere_2
{
@ -129,38 +132,34 @@ public:
const Point_2& r, const Point_2& s) const
{ return orientation(p, q, r, s); }
protected :
Point_2 _sphere;
};
template < typename K >
Orientation_sphere_2<K>::
Orientation_sphere_2(const Point_2& sphere)
: _sphere(sphere)
{ }
template < typename K >
class Coradial_sphere_2
{
public:
typedef typename K::Point_2 Point_2;
typedef bool result_type;
Coradial_sphere_2(const Point_2& sphere);
bool operator()(const Point_2& p, const Point_2 q) const
{
return collinear(_sphere, p, q) &&
( are_ordered_along_line(_sphere,p,q) || are_ordered_along_line(_sphere,q,p) );
(are_ordered_along_line(_sphere, p, q) ||
are_ordered_along_line(_sphere, q, p));
}
protected :
Point_2 _sphere;
public:
typedef bool result_type;
};
template < typename K >
@ -169,29 +168,31 @@ Coradial_sphere_2(const Point_2& sphere)
: _sphere(sphere)
{ }
template < typename K >
class Inside_cone_2
{
public:
typedef typename K::Point_2 Point_2;
typedef bool result_type;
Inside_cone_2(const Point_2& sphere);
bool operator()(const Point_2& p, const Point_2& q, const Point_2& r) const
{
if( collinear(_sphere,p,r)||collinear(_sphere,q,r)||orientation(_sphere,p,q,r)!=COLLINEAR)
if(collinear(_sphere, p, r) ||
collinear(_sphere, q, r) ||
orientation(_sphere, p, q, r) != COLLINEAR)
return false;
if(collinear(_sphere, p, q))
return true;
return coplanar_orientation(_sphere,p,q,r) == ( POSITIVE==coplanar_orientation(_sphere,q,p,r) );
return coplanar_orientation(_sphere, p, q, r) ==
(POSITIVE == coplanar_orientation(_sphere, q, p, r));
}
protected :
Point_2 _sphere;
public:
typedef bool result_type;
};
template < typename K >
@ -205,7 +206,6 @@ class Delaunay_triangulation_sphere_traits_2
: public R
{
public:
typedef typename R::Point_3 Point_2;
typedef typename R::Point_3 Weighted_point_2;
typedef typename R::Ray_3 Ray_2;
@ -225,13 +225,12 @@ public:
typedef typename R::Compute_squared_distance_3 Compute_squared_distance_2;
typedef typename R::Compare_xyz_3 Compare_xyz_3;
typedef boost::true_type requires_test;
double _radius;
typedef boost::true_type requires_test;
void set_radius(double a) { _radius = a; }
Delaunay_triangulation_sphere_traits_2(const Point_2& sphere = Point_2(0,0,0));
Compare_xyz_3
compare_xyz_3_object() const
@ -241,7 +240,6 @@ public:
compute_squared_distance_2_object() const
{ return Compute_squared_distance_2(); }
Orientation_2
orientation_2_object() const
{ return Orientation_2(_sphere); }
@ -262,25 +260,24 @@ public:
inside_cone_2_object() const
{ return Inside_cone_2(_sphere); }
Construct_ray_3 construct_ray_2_object() const
Construct_ray_3
construct_ray_2_object() const
{ return Construct_ray_3(); }
Construct_circumcenter_3
construct_circumcenter_2_object() const
{ return Construct_circumcenter_3(); }
Construct_segment_3
construct_segment_2_object() const
{ return Construct_segment_3(); }
Compute_squared_distance_2 compute_squared_distance_3_object() const
Compute_squared_distance_2
compute_squared_distance_3_object() const
{ return Compute_squared_distance_2(); }
protected :
Point_2 _sphere;
};
template < class R >
@ -289,20 +286,6 @@ Delaunay_triangulation_sphere_traits_2(const Point_2& sphere)
: _sphere(sphere)
{ }
} // namespace CGAL
#endif // CGAL_Reg_TRIANGULATION_SPHERE_TRAITS_2_H

View File

@ -1,27 +1,51 @@
// Copyright (c) 1997, 2012, 2019 INRIA Sophia-Antipolis (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 Licenxse, 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.
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
// Author(s) : Mariette Yvinec, Claudia Werner
#ifndef CGAL_PROJECTION_SPHERE_TRAITS_3_H
#define CGAL_PROJECTION_SPHERE_TRAITS_3_H
#include <CGAL/number_utils_classes.h>
#include <CGAL/triangulation_assertions.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/Delaunay_triangulation_sphere_traits_2.h>
namespace CGAL{template<typename K>
#include <CGAL/triangulation_assertions.h>
#include <CGAL/number_utils_classes.h>
#include <CGAL/Kernel_traits.h>
namespace CGAL {
template<typename K>
class Projection_sphere_traits_3;
template < typename K>
class Projected_point
: public K::Point_3{
: public K::Point_3
{
public:
typedef typename K::Point_3 Base_point;
Projected_point()
:Base_point(){}
Projected_point(const Base_point &p, const typename K::Point_3& sphere_center)
:Base_point(p){compute_scale( p-(sphere_center-ORIGIN) );}
Projected_point() : Base_point() { }
Projected_point(const Base_point& p,
const typename K::Point_3& sphere_center)
: Base_point(p)
{
compute_scale(p-(sphere_center-ORIGIN));
}
public:
double _scale;
@ -29,57 +53,56 @@ public:
void scale() { return _scale; }
private:
void compute_scale(double x, double y, double z){
void compute_scale(double x, double y, double z)
{
double tmp = x*x+y*y+z*z;
if(tmp == 0)
_scale = 0;
else
_scale = 1 / sqrt(tmp);
}
void compute_scale(const Base_point &p){
void compute_scale(const Base_point& p)
{
return compute_scale(p.x(), p.y(), p.z());
}
};
// the following two different adaptors are necessary because the Predicates don not need _sphere
// compared to Predicates from Delaunay_sphere_traits
// adaptor for calling the Predicate_ with the points projected on the sphere
template < class K, class P, class Predicate_ >
class Traits_with_projection_adaptor {
class Traits_with_projection_adaptor
{
public:
typedef Predicate_ Predicate;
typedef typename P::Point_2 Point;
typedef typename K::Point_2 Base_point;
Traits_with_projection_adaptor(Base_point sphere, double radius) : _radius(radius), _sphere(sphere) { }
double _radius;
Base_point _sphere ;
typedef typename Predicate::result_type result_type;
result_type operator()(const Point& p0, const Point& p1)
{ return Predicate(_sphere)(project(p0), project(p1)); }
result_type operator()(const Point& p0, const Point& p1, const Point& p2)
{ return Predicate(_sphere)(project(p0), project(p1), project(p2)); }
result_type operator ()(const Point& p0, const Point& p1, const Point& p2, const Point& p3)
{ return Predicate(_sphere)(project(p0), project(p1), project(p2), project(p3)); }
result_type operator()(const Point& p0, const Point& p1, const Point& p2, const Point& p3, const Point& p4)
{ return Predicate(_sphere)(project(p0), project(p1), project(p2), project(p3), project(p4)); }
private:
Base_point project (const Point& p){
Base_point project (const Point& p)
{
double scale = _radius * p._scale;
return Base_point(scale*p.x(), scale*p.y(), scale*p.z());
}
@ -87,44 +110,41 @@ private:
//adaptor for calling the Predicate_ with the points projected on the sphere for predicates from the Kernel
template < class K, class P, class Predicate_ >
class Traits_with_projection_adaptorKernel {
class Traits_with_projection_adaptorKernel
{
public:
typedef Predicate_ Predicate;
typedef typename P::Point_2 Point;
typedef typename K::Point_3 Base_point;
Traits_with_projection_adaptorKernel(double radius) : _radius(radius) { }
double _radius;
Base_point _sphere;
typedef typename Predicate::result_type result_type;
result_type operator()(const Point& p0, const Point& p1)
{ return Predicate()(project(p0), project(p1)); }
result_type operator()(const Point& p0, const Point& p1, const Point& p2)
{ return Predicate()(project(p0), project(p1), project(p2)); }
result_type operator ()(const Point& p0, const Point& p1, const Point& p2, const Point& p3)
{ return Predicate()(project(p0), project(p1), project(p2), project(p3)); }
result_type operator()(const Point& p0, const Point& p1, const Point& p2, const Point& p3, const Point& p4)
{ return Predicate()(project(p0), project(p1), project(p2), project(p3), project(p4)); }
private:
Base_point project (const Point& p){
Base_point project (const Point& p)
{
double scale = _radius * p._scale;
return Base_point(scale*p.x(), scale*p.y(), scale*p.z());
}
};
template < class R >
class Projection_sphere_traits_3
: public R
@ -140,21 +160,13 @@ public:
typedef Point_2 result_type;
typedef Traits_with_projection_adaptor<Base,Self,typename Base::Power_test_2>
Power_test_2;
typedef Traits_with_projection_adaptor<Base, Self,typename Base::Orientation_2>
Orientation_2;
typedef Traits_with_projection_adaptor<Base,Self, typename Base::Coradial_sphere_2 >
Coradial_sphere_2;
typedef Traits_with_projection_adaptor<Base,Self,typename Base::Inside_cone_2 >
Inside_cone_2;
typedef Traits_with_projection_adaptorKernel<R,Self,typename Base::Orientation_1 >
Orientation_1;
typedef Traits_with_projection_adaptorKernel<R, Self , typename Base ::Compute_squared_distance_2>
Compute_squared_distance_2;
typedef Traits_with_projection_adaptorKernel<R , Self, typename Base::Compare_xyz_3>
Compare_xyz_3;
typedef Traits_with_projection_adaptor<Base, Self, typename Base::Power_test_2> Power_test_2;
typedef Traits_with_projection_adaptor<Base, Self, typename Base::Orientation_2> Orientation_2;
typedef Traits_with_projection_adaptor<Base, Self, typename Base::Coradial_sphere_2 > Coradial_sphere_2;
typedef Traits_with_projection_adaptor<Base, Self, typename Base::Inside_cone_2 > Inside_cone_2;
typedef Traits_with_projection_adaptorKernel<R, Self, typename Base::Orientation_1 > Orientation_1;
typedef Traits_with_projection_adaptorKernel<R, Self, typename Base ::Compute_squared_distance_2> Compute_squared_distance_2;
typedef Traits_with_projection_adaptorKernel<R, Self, typename Base::Compare_xyz_3> Compare_xyz_3;
typedef boost::false_type requires_test;
@ -162,8 +174,6 @@ typedef Traits_with_projection_adaptorKernel<R , Self, typename Base::Compare_xy
Projection_sphere_traits_3(const Base_point& sphere=Base_point(0,0,0), double radius = 1);
Orientation_2
orientation_2_object() const
{ return Orientation_2(_sphere, _radius); }
@ -197,22 +207,17 @@ struct Construct_projected_point_3
{
const Base_point& sphere_center;
Point_2 operator()(const Base_point& pt) const
{ return Point_2(pt, sphere_center); }
Point_2 operator()(const Base_point& pt) const { return Point_2(pt, sphere_center); }
Construct_projected_point_3(const Base_point& sc)
:sphere_center(sc) {}
Construct_projected_point_3(const Base_point& sc) : sphere_center(sc) { }
};
Construct_projected_point_3
construct_projected_point_3_object() const {
return Construct_projected_point_3(_sphere);
};
construct_projected_point_3_object() const
{ return Construct_projected_point_3(_sphere); }
protected :
Base_point _sphere;
};
template < class R >
@ -221,11 +226,6 @@ Projection_sphere_traits_3(const Base_point& sphere, double radius)
: _radius(radius), _sphere(sphere)
{ }
} // namespace CGAL
#endif
#endif // CGAL_PROJECTION_SPHERE_TRAITS_3_H

View File

@ -1,9 +1,10 @@
// Copyright (c) 1997 INRIA Sophia-Antipolis (France).
// Copyright (c) 1997, 2012, 2019 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.
// 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 Licenxse, 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.
@ -11,17 +12,15 @@
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.4-branch/Triangulation_2/include/CGAL/Triangulation_face_base_sphere_2.h $
// $Id: Triangulation_face_base_sphere_2.h 28567 2006-02-16 14:30:13Z lsaboret $
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0+
//
// Author(s) : Mariette Yvinec, Claudia Werner
#ifndef CGAL_TRIANGULATION_FACE_BASE_SPHERE_2_H
#define CGAL_TRIANGULATION_FACE_BASE_SPHERE_2_H
#include <CGAL/basic.h>
#include <CGAL/triangulation_assertions.h>
#include <CGAL/Triangulation_ds_face_base_2.h>
namespace CGAL {
@ -30,9 +29,6 @@ template < typename Gt, typename Fb = Triangulation_ds_face_base_2<> >
class Triangulation_face_base_sphere_2
: public Fb
{
protected:
bool _ghost;
public:
typedef Gt Geom_traits;
typedef typename Fb::Vertex_handle Vertex_handle;
@ -43,21 +39,25 @@ public:
typedef typename Fb::template Rebind_TDS<TDS2>::Other Fb2;
typedef Triangulation_face_base_sphere_2<Gt, Fb2> Other;
};
unsigned char _in_conflict_flag;
public:
void set_in_conflict_flag(unsigned char f) { _in_conflict_flag = f; }
unsigned char get_in_conflict_flag() const { return _in_conflict_flag; }
public:
Triangulation_face_base_sphere_2()
: Fb(),_ghost(false) {
: Fb(), _ghost(false)
{
set_in_conflict_flag(0);
}
Triangulation_face_base_sphere_2(Vertex_handle v0,
Vertex_handle v1,
Vertex_handle v2)
: Fb(v0,v1,v2),_ghost(false) {
: Fb(v0, v1, v2), _ghost(false)
{
set_in_conflict_flag(0);
}
@ -67,50 +67,18 @@ public:
Face_handle n0,
Face_handle n1,
Face_handle n2)
: Fb(v0,v1,v2,n0,n1,n2),_ghost(false) {
: Fb(v0, v1, v2, n0, n1, n2), _ghost(false)
{
set_in_conflict_flag(0);
}
static int ccw(int i) {return Triangulation_cw_ccw_2::ccw(i);}
static int cw(int i) {return Triangulation_cw_ccw_2::cw(i);}
const bool& is_ghost() const { return _ghost; }
bool& ghost() { return _ghost; }
#ifndef CGAL_NO_DEPRECATED_CODE
Vertex_handle mirror_vertex(int i) const;
int mirror_index(int i) const;
#endif
protected:
bool _ghost;
};
#ifndef CGAL_NO_DEPRECATED_CODE
template < class Gt, class Fb >
inline
typename Triangulation_face_base_sphere_2<Gt,Fb>::Vertex_handle
Triangulation_face_base_sphere_2<Gt,Fb>::
mirror_vertex(int i) const
{
CGAL_triangulation_precondition ( this->neighbor(i) != Face_handle()
&& this->dimension() >= 1);
//return neighbor(i)->vertex(neighbor(i)->index(this->handle()));
return this->neighbor(i)->vertex(mirror_index(i));
}
template < class Gt, class Fb >
inline int
Triangulation_face_base_sphere_2<Gt,Fb>::
mirror_index(int i) const
{
// return the index of opposite vertex in neighbor(i);
CGAL_triangulation_precondition (this->neighbor(i) != Face_handle() &&
this->dimension() >= 1);
if (this->dimension() == 1) {
return 1 - (this->neighbor(i)->index(this->vertex(1-i)));
}
return this->ccw( this->neighbor(i)->index(this->vertex(this->ccw(i))));
}
#endif
} // namespace CGAL
#endif //CGAL_Triangulation_face_base_sphere_2_H

View File

@ -1,4 +1,4 @@
// Copyright (c) 1997 INRIA Sophia-Antipolis (France).
// Copyright (c) 1997, 2O12, 2019 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
@ -14,7 +14,7 @@
//
// $URL$
// $Id$
//
// SPDX-License-Identifier: GPL-3.0+
//
// Author(s) : Claudia Werner, Mariette Yvinec
@ -23,7 +23,8 @@
namespace CGAL{
template <class Triangulation_>
class Triangulation_sphere_line_face_circulator_2
:public Bidirectional_circulator_base<typename Triangulation_::Triangulation_data_structure::Face,
: public Bidirectional_circulator_base<
typename Triangulation_::Triangulation_data_structure::Face,
std::size_t>,
public Triangulation_cw_ccw_2
{
@ -32,6 +33,7 @@ public:
typedef Triangulation_ Triangulation;
typedef typename Triangulation::Geom_traits Gt;
typedef typename Triangulation_::Triangulation_data_structure Tds;
typedef typename Tds::Vertex Vertex;
typedef typename Tds::Face Face;
typedef typename Tds::Edge Edge;
@ -42,7 +44,6 @@ public:
typedef typename Gt::Point_2 Point;
typedef typename Triangulation::Locate_type Locate_type;
enum State {undefined = -1,
vertex_vertex,
vertex_edge,
@ -65,7 +66,6 @@ public:
const Triangulation* tr,
const Point& dir);
Line_face_circulator& operator++() ;
Line_face_circulator& operator--() ;
Line_face_circulator operator++(int);
@ -73,6 +73,7 @@ public:
Face* operator->() { return &*pos; }
Face& operator*() { return *pos; }
Face_handle handle() { return pos; }
operator const Face_handle() const { return pos; }
bool operator==(const Line_face_circulator& lfc) const;
bool operator!=(const Line_face_circulator& lfc) const;
@ -115,8 +116,6 @@ private:
return (fc != fh);
}
template < class Triangulation >
Triangulation_sphere_line_face_circulator_2<Triangulation>::
Triangulation_sphere_line_face_circulator_2(Vertex_handle v,
@ -138,47 +137,48 @@ private:
int ic = fc->index(v);
Vertex_handle vt = fc->vertex(cw(ic));
//Orientation o = _tr->orientation(p, q, vt->point());
while( _tr->orientation(p, q, vt->point()) != LEFT_TURN) {
while( _tr->orientation(p, q, vt->point()) != LEFT_TURN)
{
++fc;
ic = fc->index(v);
vt= fc->vertex(cw(ic));
if (fc == done) { *this = Line_face_circulator(); return;}
if(fc == done)
{
*this = Line_face_circulator();
return;
}
}
Vertex_handle vr = fc-> vertex(ccw(ic));
Orientation pqr = RIGHT_TURN; // warning "pqr might be used uninitialized"
while ( (pqr = _tr->orientation(p, q, vr->point()))== LEFT_TURN ) {
while((pqr = _tr->orientation(p, q, vr->point())) == LEFT_TURN)
{
--fc;
ic = fc->index(v);
vr = fc-> vertex(ccw(ic));
}
// first intersected face found
// [pqr] is COLLINEAR or RIGHT_TURN
ic = fc->index(v);
vt= fc->vertex(cw(ic));
CGAL_triangulation_assertion (_tr->orientation(p,q, vt->point())==
LEFT_TURN );
CGAL_triangulation_assertion (_tr->orientation(p, q, vt->point()) == LEFT_TURN);
if (pqr == COLLINEAR) {
if(pqr == COLLINEAR)
{
pos = fc;
s = vertex_vertex;
i = ccw(ic);
}
else { // pqr==RIGHT_TURN
else // pqr == RIGHT_TURN
{
pos = fc;
s = vertex_edge;
i = ic ;
}
return;
}
template < class Triangulation >
inline
void
@ -186,9 +186,11 @@ private:
increment()
{
CGAL_triangulation_precondition(pos != Face_handle());
if(s == vertex_vertex || s == edge_vertex) {
if(s == vertex_vertex || s == edge_vertex)
{
Orientation o;
do{
do
{
Face_handle n = pos->neighbor(cw(i));
i = n->index(pos);
pos = n;
@ -197,21 +199,25 @@ private:
i = cw(i);
} while(o == LEFT_TURN);
if(o == COLLINEAR) {
if(o == COLLINEAR)
{
s = vertex_vertex;
i = ccw(i);
}
else {
else
{
s = vertex_edge;
}
}
else {
else
{
Face_handle n = pos->neighbor(i);
int ni = n->index(pos);
pos = n ;
Orientation o = _tr->orientation(p, q, pos->vertex(ni)->point());
switch(o){
switch(o)
{
case LEFT_TURN:
s = edge_edge;
i = ccw(ni);
@ -233,33 +239,33 @@ private:
decrement()
{
CGAL_triangulation_precondition(pos != Face_handle());
if(s == vertex_vertex || s == vertex_edge) {
if(s == vertex_vertex){
if(s == vertex_vertex || s == vertex_edge)
{
if(s == vertex_vertex)
i = cw(i);
}
Orientation o;
do{
do
{
Face_handle n = pos->neighbor(ccw(i));
i = n->index(pos);
pos = n;
o = _tr->orientation(p, q, pos->vertex(i)->point());
i = ccw(i);
}while(o == LEFT_TURN);
}
while(o == LEFT_TURN);
s = (o == COLLINEAR) ? vertex_vertex : edge_vertex;
}
else { // s == edge_edge || s == edge_vertex
else // s == edge_edge || s == edge_vertex
{
// the following is not nice. A better solution is to say
// that index i is at the vertex that is alone on one side of l(p, q)
if(s == edge_edge){
i = (_tr->orientation
(p, q,
pos->vertex(i)->point()) ==
LEFT_TURN)
? cw(i) : ccw(i);
}
if(s == edge_edge)
i = (_tr->orientation(p, q, pos->vertex(i)->point()) == LEFT_TURN) ? cw(i) : ccw(i);
Face_handle n = pos->neighbor(i);
i = n->index(pos);
pos = n;
@ -269,8 +275,6 @@ private:
}
}
template < class Triangulation >
inline
Triangulation_sphere_line_face_circulator_2<Triangulation>&
@ -320,8 +324,7 @@ private:
Triangulation_sphere_line_face_circulator_2<Triangulation>::
operator==(const Line_face_circulator& lfc) const
{
CGAL_triangulation_precondition( pos != Face_handle() &&
lfc.pos != Face_handle());
CGAL_triangulation_precondition(pos != Face_handle() && lfc.pos != Face_handle());
return (pos == lfc.pos && _tr == lfc._tr &&
s == lfc.s && p==lfc.p && q==lfc.q);
}
@ -360,7 +363,6 @@ private:
return !(*this == n);
}
} // end namespace CGAL
}//namespace
#endif