mirror of https://github.com/CGAL/cgal
merge change from next
This commit is contained in:
commit
00c7151ce0
|
|
@ -4285,6 +4285,7 @@ Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_2.cpp -t
|
||||||
Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_regular_2.cpp -text
|
Triangulation_2/examples/Triangulation_2/info_insert_with_pair_iterator_regular_2.cpp -text
|
||||||
Triangulation_2/examples/Triangulation_2/info_insert_with_transform_iterator_2.cpp -text
|
Triangulation_2/examples/Triangulation_2/info_insert_with_transform_iterator_2.cpp -text
|
||||||
Triangulation_2/examples/Triangulation_2/info_insert_with_zip_iterator_2.cpp -text
|
Triangulation_2/examples/Triangulation_2/info_insert_with_zip_iterator_2.cpp -text
|
||||||
|
Triangulation_2/examples/Triangulation_2/polygon_triangulation.cpp -text
|
||||||
Triangulation_2/test/Triangulation_2/test_delaunay_triangulation_proj.cpp -text
|
Triangulation_2/test/Triangulation_2/test_delaunay_triangulation_proj.cpp -text
|
||||||
Triangulation_3/demo/Triangulation_3/CMakeLists.txt -text
|
Triangulation_3/demo/Triangulation_3/CMakeLists.txt -text
|
||||||
Triangulation_3/demo/Triangulation_3/MainWindow.cpp -text
|
Triangulation_3/demo/Triangulation_3/MainWindow.cpp -text
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
#include <CGAL/array.h>
|
#include <CGAL/array.h>
|
||||||
#include <CGAL/Handle_for.h>
|
#include <CGAL/Handle_for.h>
|
||||||
#include <CGAL/Cartesian/solve_3.h>
|
#include <CGAL/Cartesian/solve_3.h>
|
||||||
|
#include <CGAL/Cartesian/plane_constructions_3.h>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
template <class R_>
|
||||||
|
class PlaneC3;
|
||||||
|
|
||||||
template <class R>
|
template <class R>
|
||||||
CGAL_KERNEL_LARGE_INLINE
|
CGAL_KERNEL_LARGE_INLINE
|
||||||
PlaneC3<R>
|
PlaneC3<R>
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,8 @@ public:
|
||||||
result_type
|
result_type
|
||||||
operator()(const Segment_3 &s, const Bbox_3& b) const
|
operator()(const Segment_3 &s, const Bbox_3& b) const
|
||||||
{
|
{
|
||||||
CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Do_intersect_3", tmp);
|
CGAL_BRANCH_PROFILER_3(std::string("semi-static failures/attempts/calls to : ") +
|
||||||
|
std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||||
|
|
||||||
Get_approx<Point_3> get_approx; // Identity functor for all points
|
Get_approx<Point_3> get_approx; // Identity functor for all points
|
||||||
// but lazy points
|
// but lazy points
|
||||||
|
|
@ -309,7 +310,8 @@ public:
|
||||||
result_type
|
result_type
|
||||||
operator()(const Ray_3 &r, const Bbox_3& b) const
|
operator()(const Ray_3 &r, const Bbox_3& b) const
|
||||||
{
|
{
|
||||||
CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Do_intersect_3", tmp);
|
CGAL_BRANCH_PROFILER_3(std::string("semi-static failures/attempts/calls to : ") +
|
||||||
|
std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||||
|
|
||||||
Get_approx<Point_3> get_approx; // Identity functor for all points
|
Get_approx<Point_3> get_approx; // Identity functor for all points
|
||||||
// but lazy points.
|
// but lazy points.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
|
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
||||||
|
#include <CGAL/Triangulation_face_base_with_info_2.h>
|
||||||
|
#include <CGAL/Polygon_2.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
struct FaceInfo2
|
||||||
|
{
|
||||||
|
FaceInfo2(){}
|
||||||
|
int nesting_level;
|
||||||
|
|
||||||
|
bool in_domain(){
|
||||||
|
return nesting_level%2 == 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||||
|
typedef CGAL::Triangulation_vertex_base_2<K> Vb;
|
||||||
|
typedef CGAL::Triangulation_face_base_with_info_2<FaceInfo2,K> Fbb;
|
||||||
|
typedef CGAL::Constrained_triangulation_face_base_2<K,Fbb> Fb;
|
||||||
|
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> TDS;
|
||||||
|
typedef CGAL::Exact_predicates_tag Itag;
|
||||||
|
typedef CGAL::Constrained_Delaunay_triangulation_2<K, TDS, Itag> CDT;
|
||||||
|
typedef CDT::Point Point;
|
||||||
|
typedef CGAL::Polygon_2<K> Polygon;
|
||||||
|
|
||||||
|
void
|
||||||
|
mark_domains(CDT& ct,
|
||||||
|
CDT::Face_handle start,
|
||||||
|
int index,
|
||||||
|
std::list<CDT::Edge>& border )
|
||||||
|
{
|
||||||
|
if(start->info().nesting_level != -1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::list<CDT::Face_handle> queue;
|
||||||
|
queue.push_back(start);
|
||||||
|
|
||||||
|
while(! queue.empty()){
|
||||||
|
CDT::Face_handle fh = queue.front();
|
||||||
|
queue.pop_front();
|
||||||
|
if(fh->info().nesting_level == -1){
|
||||||
|
fh->info().nesting_level = index;
|
||||||
|
for(int i = 0; i < 3; i++){
|
||||||
|
CDT::Edge e(fh,i);
|
||||||
|
CDT::Face_handle n = fh->neighbor(i);
|
||||||
|
if(n->info().nesting_level == -1){
|
||||||
|
if(ct.is_constrained(e)) border.push_back(e);
|
||||||
|
else queue.push_back(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//explore set of facets connected with non constrained edges,
|
||||||
|
//and attribute to each such set a nesting level.
|
||||||
|
//We start from facets incident to the infinite vertex, with a nesting
|
||||||
|
//level of 0. Then we recursively consider the non-explored facets incident
|
||||||
|
//to constrained edges bounding the former set and increase the nesting level by 1.
|
||||||
|
//Facets in the domain are those with an odd nesting level.
|
||||||
|
void
|
||||||
|
mark_domains(CDT& cdt)
|
||||||
|
{
|
||||||
|
for(CDT::All_faces_iterator it = cdt.all_faces_begin(); it != cdt.all_faces_end(); ++it){
|
||||||
|
it->info().nesting_level = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
std::list<CDT::Edge> border;
|
||||||
|
mark_domains(cdt, cdt.infinite_face(), index++, border);
|
||||||
|
while(! border.empty()){
|
||||||
|
CDT::Edge e = border.front();
|
||||||
|
border.pop_front();
|
||||||
|
CDT::Face_handle n = e.first->neighbor(e.second);
|
||||||
|
if(n->info().nesting_level == -1){
|
||||||
|
mark_domains(cdt, n, e.first->info().nesting_level+1, border);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void insert_polygon(CDT& cdt,const Polygon& polygon){
|
||||||
|
if ( polygon.is_empty() ) return;
|
||||||
|
CDT::Vertex_handle v_prev=cdt.insert(*CGAL::cpp0x::prev(polygon.vertices_end()));
|
||||||
|
for (Polygon::Vertex_iterator vit=polygon.vertices_begin();
|
||||||
|
vit!=polygon.vertices_end();++vit)
|
||||||
|
{
|
||||||
|
CDT::Vertex_handle vh=cdt.insert(*vit);
|
||||||
|
cdt.insert_constraint(vh,v_prev);
|
||||||
|
v_prev=vh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( )
|
||||||
|
{
|
||||||
|
//construct two non-intersecting nested polygons
|
||||||
|
Polygon polygon1;
|
||||||
|
polygon1.push_back(Point(0,0));
|
||||||
|
polygon1.push_back(Point(2,0));
|
||||||
|
polygon1.push_back(Point(2,2));
|
||||||
|
polygon1.push_back(Point(0,2));
|
||||||
|
Polygon polygon2;
|
||||||
|
polygon2.push_back(Point(0.5,0.5));
|
||||||
|
polygon2.push_back(Point(1.5,0.5));
|
||||||
|
polygon2.push_back(Point(1.5,1.5));
|
||||||
|
polygon2.push_back(Point(0.5,1.5));
|
||||||
|
|
||||||
|
//Insert the polyons into a constrained triangulation
|
||||||
|
CDT cdt;
|
||||||
|
insert_polygon(cdt,polygon1);
|
||||||
|
insert_polygon(cdt,polygon2);
|
||||||
|
|
||||||
|
//Mark facets that are inside the domain bounded by the polygon
|
||||||
|
mark_domains(cdt);
|
||||||
|
|
||||||
|
int count=0;
|
||||||
|
for (CDT::Finite_faces_iterator fit=cdt.finite_faces_begin();
|
||||||
|
fit!=cdt.finite_faces_end();++fit)
|
||||||
|
{
|
||||||
|
if ( fit->info().in_domain() ) ++count;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "There are " << count << " facets in the domain." << std::endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue