Merge branch 'Operations_on_polyhedra-BGLization-GF'

Approved by the release manager
This commit is contained in:
Andreas Fabri 2015-01-12 11:31:06 +01:00
commit 02b26e679c
4 changed files with 106 additions and 9 deletions

View File

@ -0,0 +1,54 @@
// Copyright (c) 2004 Max-Planck-Institute Saarbruecken (Germany).
// 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.
//
// $URL$
// $Id$
//
//
// Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de>
// Andreas Meyer <ameyer@mpi-sb.mpg.de>
#ifndef CGAL_BOX_INTERSECTION_D_BOX_WITH_INFO_D_H
#define CGAL_BOX_INTERSECTION_D_BOX_WITH_INFO_D_H
#include <CGAL/basic.h>
#include <CGAL/Box_intersection_d/Box_d.h>
namespace CGAL {
namespace Box_intersection_d {
template<class NT_, int N, class Info_>
class Box_with_info_d : public Box_d< NT_, N, ID_FROM_BOX_ADDRESS> {
protected:
Info_ m_info;
public:
typedef Box_d< NT_, N, ID_FROM_BOX_ADDRESS> Base;
typedef NT_ NT;
typedef Info_ Info;
Box_with_info_d() {}
Box_with_info_d( Info h) : m_info(h) {}
Box_with_info_d( bool complete, Info h): Base(complete), m_info(h) {}
Box_with_info_d(NT l[N], NT h[N], Info n) : Base( l, h), m_info(n) {}
Box_with_info_d( const Bbox_2& b, Info h) : Base( b), m_info(h) {}
Box_with_info_d( const Bbox_3& b, Info h) : Base( b), m_info(h) {}
Info info() const { return m_info; }
};
} // end namespace Box_intersection_d
} //namespace CGAL
#endif

View File

@ -25,6 +25,7 @@
#include <CGAL/Box_intersection_d/segment_tree.h>
#include <CGAL/Box_intersection_d/Box_d.h>
#include <CGAL/Box_intersection_d/Box_with_handle_d.h>
#include <CGAL/Box_intersection_d/Box_with_info_d.h>
#include <CGAL/Box_intersection_d/Box_traits_d.h>
#include <CGAL/Box_intersection_d/box_limits.h>

View File

@ -0,0 +1,42 @@
#include <iostream>
#include <fstream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
#include <CGAL/Self_intersection_polyhedron_3.h>
#include <CGAL/Timer.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
int main(int, char** argv) {
std::ifstream input(argv[1]);
Mesh m;
if ( !input || !(input >> m) ){
std::cerr << "Error: can not read file.";
return 1;
}
CGAL::Timer timer;
timer.start();
std::vector<std::pair<face_descriptor, face_descriptor> > intersected_tris;
bool intersecting_1 = CGAL::self_intersect<K>(m, back_inserter(intersected_tris)).first;
assert(intersecting_1 == !intersected_tris.empty());
std::cerr << "Self-intersection test took " << timer.time() << " sec." << std::endl;
std::cerr << intersected_tris.size() << " pair of triangles are intersecting." << std::endl;
timer.reset();
bool intersecting_2 = CGAL::self_intersect<K>(m);
assert(intersecting_1 == intersecting_2);
std::cerr << "Is self-intersection test took " << timer.time() << " sec." << std::endl;
std::cerr << (intersecting_2 ? "There is a self-intersection." : "There is no self-intersection.") << std::endl;
return 0;
}

View File

@ -89,16 +89,16 @@ struct Intersect_facets
void operator()(const Box* b,
const Box* c) const
{
halfedge_descriptor h = halfedge(b->handle(),m_polyhedron);
halfedge_descriptor h = halfedge(b->info(),m_polyhedron);
// check for shared egde --> no intersection
if(face(opposite(h,m_polyhedron),m_polyhedron) == c->handle() ||
face(opposite(next(h,m_polyhedron),m_polyhedron),m_polyhedron) == c->handle() ||
face(opposite(next(next(h,m_polyhedron),m_polyhedron),m_polyhedron),m_polyhedron) == c->handle())
if(face(opposite(h,m_polyhedron),m_polyhedron) == c->info() ||
face(opposite(next(h,m_polyhedron),m_polyhedron),m_polyhedron) == c->info() ||
face(opposite(next(next(h,m_polyhedron),m_polyhedron),m_polyhedron),m_polyhedron) == c->info())
return;
// check for shared vertex --> maybe intersection, maybe not
halfedge_descriptor g = halfedge(c->handle(),m_polyhedron);
halfedge_descriptor g = halfedge(c->info(),m_polyhedron);
halfedge_descriptor v;
if(target(h,m_polyhedron) == target(g,m_polyhedron))
@ -138,9 +138,9 @@ struct Intersect_facets
Segment s2 = segment_functor( m_point[target(next(v,m_polyhedron),m_polyhedron)], m_point[target(next(next(v,m_polyhedron),m_polyhedron),m_polyhedron)]);
if(do_intersect_3_functor(t1,s2)){
*m_iterator_wrapper++ = std::make_pair(b->handle(), c->handle());
*m_iterator_wrapper++ = std::make_pair(b->info(), c->info());
} else if(do_intersect_3_functor(t2,s1)){
*m_iterator_wrapper++ = std::make_pair(b->handle(), c->handle());
*m_iterator_wrapper++ = std::make_pair(b->info(), c->info());
}
return;
}
@ -149,7 +149,7 @@ struct Intersect_facets
Triangle t1 = triangle_functor( m_point[target(h,m_polyhedron)], m_point[target(next(h,m_polyhedron),m_polyhedron)], m_point[target(next(next(h,m_polyhedron),m_polyhedron),m_polyhedron)]);
Triangle t2 = triangle_functor( m_point[target(g,m_polyhedron)], m_point[target(next(g,m_polyhedron),m_polyhedron)], m_point[target(next(next(g,m_polyhedron),m_polyhedron),m_polyhedron)]);
if(do_intersect_3_functor(t1, t2)){
*m_iterator_wrapper++ = std::make_pair(b->handle(), c->handle());
*m_iterator_wrapper++ = std::make_pair(b->info(), c->info());
}
} // end operator ()
}; // end struct Intersect_facets
@ -226,7 +226,7 @@ self_intersect(const FaceGraph& polyhedron, OutputIterator out, const GeomTraits
typedef typename boost::graph_traits<FaceGraph>::face_descriptor Facet_hdl;
typedef typename CGAL::Box_intersection_d::Box_with_handle_d<double, 3, Facet_hdl> Box;
typedef typename CGAL::Box_intersection_d::Box_with_info_d<double, 3, Facet_hdl> Box;
typedef typename boost::property_map<FaceGraph, CGAL::vertex_point_t>::const_type Ppmap;