mirror of https://github.com/CGAL/cgal
- added test_conforming and test_meshing in test/ with test files.
- rename test/Mesh_2/makefile to GNUmakefile, not submitted:
makefiles in the testsuite are generated.
- fix a BUG in Mesher_level: one_step() and try_to_insert_one_point(), in
Null_mesher_level must return false! This fix solves the "follow under
mouse" bug of mesh_demo.C!
- change some DEBUG macro names to:
CGAL_MESH_2_DEBUG_BAD_FACES
CGAL_MESH_2_DEBUG_CLUSTERS
CGAL_MESH_2_DEBUG_CONFLICTS_ZONE
CGAL_MESH_2_DEBUG_DRAW
CGAL_MESH_2_DEBUG_INSERTIONS
CGAL_MESH_2_VERBOSE
to please CGAL developer manual.
- add a seed in fish.poly
(Note to Andreas: this is the bug I was looking for. The added test file
helped me to find it cause.)
This commit is contained in:
parent
6dc795fc1f
commit
0161de5a27
|
|
@ -1127,6 +1127,11 @@ Mesh_2/doc_tex/Mesh_2/example-conform.eps -text svneol=unset#unset
|
|||
Mesh_2/doc_tex/Mesh_2/example-conform.png -text svneol=unset#unset
|
||||
Mesh_2/doc_tex/Mesh_2_ref/part_of_a_cluster.eps -text
|
||||
Mesh_2/doc_tex/Mesh_2_ref/part_of_a_cluster.gif -text svneol=unset#unset
|
||||
Mesh_2/test/Mesh_2/fish-and-rectangle.poly -text
|
||||
Mesh_2/test/Mesh_2/fish.edg -text
|
||||
Mesh_2/test/Mesh_2/fish.poly -text
|
||||
Mesh_2/test/Mesh_2/test_conforming.C -text
|
||||
Mesh_2/test/Mesh_2/test_meshing.C -text
|
||||
Mesh_3/applications/off_to_medit.C -text
|
||||
Mesh_3/examples/Mesh_3/implicit_functions.C -text
|
||||
Mesh_3/examples/Mesh_3/implicit_functions.h -text
|
||||
|
|
|
|||
|
|
@ -68,8 +68,10 @@ Mesh_2/examples/Mesh_2/semantic.cache
|
|||
Mesh_2/include/CGAL/semantic.cache
|
||||
Mesh_2/test/Mesh_2/*.core
|
||||
Mesh_2/test/Mesh_2/semantic.cache
|
||||
Mesh_2/test/Mesh_2/test_conforming
|
||||
Mesh_2/test/Mesh_2/test_double_map
|
||||
Mesh_2/test/Mesh_2/test_filtred_container
|
||||
Mesh_2/test/Mesh_2/test_meshing
|
||||
Mesh_3/*.tags.xml
|
||||
Mesh_3/applications/*.exe
|
||||
Mesh_3/applications/*.maillage
|
||||
|
|
|
|||
|
|
@ -1,3 +1,20 @@
|
|||
13 April 2006 Laurent Rineau
|
||||
- added test_conforming and test_meshing in test/ with test files.
|
||||
- rename test/Mesh_2/makefile to GNUmakefile, not submitted:
|
||||
makefiles in the testsuite are generated.
|
||||
- fix a BUG in Mesher_level: one_step() and try_to_insert_one_point(), in
|
||||
Null_mesher_level must return false! This fix solves the "follow under
|
||||
mouse" bug of mesh_demo.C!
|
||||
- change some DEBUG macro names to:
|
||||
CGAL_MESH_2_DEBUG_BAD_FACES
|
||||
CGAL_MESH_2_DEBUG_CLUSTERS
|
||||
CGAL_MESH_2_DEBUG_CONFLICTS_ZONE
|
||||
CGAL_MESH_2_DEBUG_DRAW
|
||||
CGAL_MESH_2_DEBUG_INSERTIONS
|
||||
CGAL_MESH_2_VERBOSE
|
||||
to please CGAL developer manual.
|
||||
- add a seed in fish.poly
|
||||
|
||||
20 March 2006 Laurent Rineau
|
||||
- fix a desynch between the doc and code: is_marked->is_in_domain, in the
|
||||
face base type
|
||||
|
|
|
|||
|
|
@ -20,20 +20,21 @@
|
|||
|
||||
16 0
|
||||
1 15 14
|
||||
2 2 4
|
||||
3 1 2
|
||||
4 3 1
|
||||
5 5 3
|
||||
6 6 4
|
||||
7 12 10
|
||||
8 5 7
|
||||
9 10 9
|
||||
10 7 8
|
||||
11 8 6
|
||||
12 9 11
|
||||
13 12 11
|
||||
14 13 15
|
||||
15 1 13
|
||||
16 14 1
|
||||
2 5 3
|
||||
3 3 1
|
||||
4 6 4
|
||||
5 4 2
|
||||
6 12 10
|
||||
7 5 7
|
||||
8 10 9
|
||||
9 7 8
|
||||
10 8 6
|
||||
11 9 11
|
||||
12 12 11
|
||||
13 13 15
|
||||
14 14 1
|
||||
15 13 1
|
||||
16 2 1
|
||||
|
||||
0
|
||||
1
|
||||
1 0.505223 0.0994429
|
||||
|
|
|
|||
|
|
@ -988,22 +988,25 @@ public slots:
|
|||
if(follow_mouse->is_active())
|
||||
{
|
||||
typedef Tr::Face_handle Face_handle;
|
||||
std::list<Face_handle> l;
|
||||
|
||||
Face_handle fh = cdt.locate(p);
|
||||
criteria.set_point(p);
|
||||
if( (fh!=NULL) && (!cdt.is_infinite(fh)) && fh->is_in_domain() )
|
||||
{
|
||||
criteria.set_local_size(true);
|
||||
criteria.set_point(p);
|
||||
|
||||
std::list<Face_handle> l;
|
||||
|
||||
Criteria::Quality q;
|
||||
if(criteria.is_bad_object().operator()(fh, q) !=
|
||||
CGAL::Mesh_2::NOT_BAD)
|
||||
l.push_back(fh);
|
||||
}
|
||||
if( mesher!=0 )
|
||||
{
|
||||
mesher->set_criteria(criteria);
|
||||
mesher->set_bad_faces(l.begin(), l.end());
|
||||
while( mesher->step_by_step_refine_mesh() );
|
||||
|
||||
if( mesher!=0 )
|
||||
{
|
||||
mesher->set_criteria(criteria, false);
|
||||
mesher->set_bad_faces(l.begin(), l.end());
|
||||
while( mesher->step_by_step_refine_mesh() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1334,15 +1337,18 @@ public slots:
|
|||
|
||||
void setLocal(bool checked)
|
||||
{
|
||||
criteria.set_local_size(checked);
|
||||
if( mesher == 0 )
|
||||
{
|
||||
mesher = create_mesher();
|
||||
mesher->init();
|
||||
emit initializedMesher();
|
||||
}
|
||||
mesher->set_criteria(criteria);
|
||||
if(criteria.is_local_size())
|
||||
if(checked == false)
|
||||
{
|
||||
criteria.set_local_size(false);
|
||||
mesher->set_criteria(criteria);
|
||||
}
|
||||
if(checked)
|
||||
follow_mouse->activate();
|
||||
else
|
||||
follow_mouse->deactivate();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2004 INRIA Sophia-Antipolis (France).
|
||||
// Copyright (c) 2004-2006 INRIA Sophia-Antipolis (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you may redistribute it under
|
||||
|
|
@ -487,6 +487,9 @@ public:
|
|||
*/
|
||||
void after_insertion_impl(const Vertex_handle& v)
|
||||
{
|
||||
#ifdef CGAL_MESH_2_VERBOSE
|
||||
std::cerr << "E";
|
||||
#endif
|
||||
// @todo Perhaps we should remove destroyed edges too.
|
||||
// @warning This code has been rewroten!
|
||||
|
||||
|
|
|
|||
|
|
@ -128,23 +128,23 @@ public:
|
|||
|
||||
void after_insertion_impl(const Vertex_handle& v)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef CGAL_MESH_2_DEBUG_CLUSTERS
|
||||
std::cerr << "update_clusters" << std::endl;
|
||||
std::cerr << "va_has_a_cluster=" << va_has_a_cluster
|
||||
<< std::endl
|
||||
<< "vb_has_a_cluster=" << vb_has_a_cluster
|
||||
<< std::endl;
|
||||
std::cerr << "clusters.size()=" << clusters.size() << std::endl;
|
||||
#endif // DEBUG
|
||||
#endif // CGAL_MESH_2_DEBUG_CLUSTERS
|
||||
Super::after_insertion_impl(v);
|
||||
if( va_has_a_cluster )
|
||||
clusters.update_cluster(ca,ca_it,this->va,this->vb,v,cluster_splitted);
|
||||
if( vb_has_a_cluster )
|
||||
clusters.update_cluster(cb,cb_it,this->vb,this->va,v,cluster_splitted);
|
||||
#ifdef DEBUG
|
||||
#ifdef CGAL_MESH_2_DEBUG_CLUSTERS
|
||||
std::cerr << "clusters.size() after update_cluster="
|
||||
<< clusters.size() << std::endl;
|
||||
#endif // DEBUG
|
||||
#endif // CGAL_MESH_2_DEBUG_CLUSTERS
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -91,6 +91,11 @@ public:
|
|||
bad. */
|
||||
void scan_triangulation_impl()
|
||||
{
|
||||
bad_faces.clear();
|
||||
#ifdef CGAL_MESH_2_DEBUG_BAD_FACES
|
||||
std::cerr << "bad_faces.clear()\n";
|
||||
#endif // CGAL_MESH_2_DEBUG_BAD_FACES
|
||||
|
||||
for(typename Tr::Finite_faces_iterator fit =
|
||||
triangulation_ref_impl().finite_faces_begin();
|
||||
fit != triangulation_ref_impl().finite_faces_end();
|
||||
|
|
@ -116,11 +121,11 @@ public:
|
|||
std::back_inserter(zone.boundary_edges),
|
||||
fh
|
||||
);
|
||||
#ifdef DEBUG
|
||||
#ifdef CGAL_MESH_2_DEBUG_CONFLICTS_ZONE
|
||||
std::cerr << "get_conflicts_and_boundary(" << p << "):" << std::endl
|
||||
<< "faces: " << zone.faces.size() << std::endl
|
||||
<< "edges: " << zone.boundary_edges.size() << std::endl;
|
||||
#endif // DEBUG
|
||||
#endif // CGAL_MESH_2_DEBUG_CONFLICTS_ZONE
|
||||
return zone;
|
||||
}
|
||||
|
||||
|
|
@ -183,6 +188,9 @@ public:
|
|||
/** Restore markers in the star of \c v. */
|
||||
void after_insertion_impl(const Vertex_handle& v)
|
||||
{
|
||||
#ifdef CGAL_MESH_2_VERBOSE
|
||||
std::cerr << "*";
|
||||
#endif
|
||||
typename Tr::Face_circulator fc =
|
||||
triangulation_ref_impl().incident_faces(v), fcbegin(fc);
|
||||
do {
|
||||
|
|
@ -229,6 +237,9 @@ public:
|
|||
void set_bad_faces(Fh_it begin, Fh_it end)
|
||||
{
|
||||
bad_faces.clear();
|
||||
#ifdef CGAL_MESH_2_DEBUG_BAD_FACES
|
||||
std::cerr << "bad_faces.clear()\n";
|
||||
#endif // CGAL_MESH_2_DEBUG_BAD_FACES
|
||||
for(Fh_it pfit=begin; pfit!=end; ++pfit)
|
||||
push_in_bad_faces(*pfit, Quality());
|
||||
}
|
||||
|
|
@ -242,12 +253,12 @@ inline
|
|||
void Refine_faces_base<Tr, Criteria, Previous>::
|
||||
push_in_bad_faces(Face_handle fh, const Quality& q)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef CGAL_MESH_2_DEBUG_BAD_FACES
|
||||
std::cerr << "push_in_bad_faces("
|
||||
<< fh->vertex(0)->point() << ","
|
||||
<< fh->vertex(1)->point() << ","
|
||||
<< fh->vertex(2)->point() << ")\n";
|
||||
#endif // DEBUG
|
||||
#endif // CGAL_MESH_2_DEBUG_BAD_FACES
|
||||
CGAL_assertion_code
|
||||
(typename Geom_traits::Orientation_2 orientation =
|
||||
triangulation_ref_impl().geom_traits().orientation_2_object()
|
||||
|
|
@ -264,12 +275,12 @@ inline
|
|||
void Refine_faces_base<Tr, Criteria, Previous>::
|
||||
remove_bad_face(Face_handle fh)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef CGAL_MESH_2_DEBUG_BAD_FACES
|
||||
std::cerr << "bad_faces.erase("
|
||||
<< fh->vertex(0)->point() << ","
|
||||
<< fh->vertex(1)->point() << ","
|
||||
<< fh->vertex(2)->point() << ")\n";
|
||||
#endif // DEBUG
|
||||
#endif // CGAL_MESH_2_DEBUG_BAD_FACES
|
||||
bad_faces.erase(fh);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ struct Triangulation_mesher_level_traits_2 :
|
|||
|
||||
Vertex_handle insert_impl(const Point& p, Zone& zone)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef CGAL_MESH_2_DEBUG_INSERTIONS
|
||||
std::cerr << "insert(" << p << "): "
|
||||
<< zone.boundary_edges.size() << " edges." << std::endl;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -47,13 +47,13 @@ struct Null_mesher_level {
|
|||
template <typename Visitor>
|
||||
bool try_to_insert_one_point(Visitor)
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Visitor>
|
||||
bool one_step(Visitor)
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}; // end Null_mesher_level
|
||||
|
|
|
|||
|
|
@ -13,23 +13,19 @@ include $(CGAL_MAKEFILE)
|
|||
# compiler flags
|
||||
#---------------------------------------------------------------------#
|
||||
|
||||
CXXFLAGS = -I../../include\
|
||||
$(TESTSUITE_CXXFLAGS) \
|
||||
$(EXTRA_FLAGS) \
|
||||
CXXFLAGS = \
|
||||
-I../../include \
|
||||
$(CGAL_CXXFLAGS) \
|
||||
$(LONG_NAME_PROBLEM_CXXFLAGS) \
|
||||
$(DEBUG_OPT)
|
||||
$(LONG_NAME_PROBLEM_CXXFLAGS)
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
# linker flags
|
||||
#---------------------------------------------------------------------#
|
||||
|
||||
LIBPATH = \
|
||||
$(TESTSUITE_LIBPATH) \
|
||||
$(CGAL_LIBPATH)
|
||||
|
||||
LDFLAGS = \
|
||||
$(TESTSUITE_LDFLAGS) \
|
||||
$(LONG_NAME_PROBLEM_LDFLAGS) \
|
||||
$(CGAL_LDFLAGS)
|
||||
|
||||
|
|
@ -38,21 +34,34 @@ LDFLAGS = \
|
|||
#---------------------------------------------------------------------#
|
||||
|
||||
all: \
|
||||
test_conforming$(EXE_EXT) \
|
||||
test_double_map$(EXE_EXT) \
|
||||
test_filtred_container$(EXE_EXT) \
|
||||
test_double_map$(EXE_EXT)
|
||||
test_meshing$(EXE_EXT)
|
||||
|
||||
test_filtred_container$(EXE_EXT): test_filtred_container$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)test_filtred_container test_filtred_container$(OBJ_EXT) $(LDFLAGS)
|
||||
test_conforming$(EXE_EXT): test_conforming$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)test_conforming test_conforming$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
test_double_map$(EXE_EXT): test_double_map$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)test_double_map test_double_map$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
test_filtred_container$(EXE_EXT): test_filtred_container$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)test_filtred_container test_filtred_container$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
test_meshing$(EXE_EXT): test_meshing$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)test_meshing test_meshing$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
clean: \
|
||||
test_conforming.clean \
|
||||
test_double_map.clean \
|
||||
test_filtred_container.clean \
|
||||
test_double_map.clean
|
||||
test_meshing.clean
|
||||
|
||||
|
||||
run: all
|
||||
./test_conforming
|
||||
./test_filtred_container
|
||||
./test_meshing
|
||||
./test_double_map
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
# Shewchuk Triangle .poly file, produced by the CGAL::Mesh_2 package
|
||||
# Neither attributes nor boundary markers are used.
|
||||
31 2 0 0
|
||||
|
||||
1 -0.25 0
|
||||
2 -0.5 1
|
||||
3 -0.5 -1
|
||||
4 0 0.5
|
||||
5 0 -0.5
|
||||
6 0.5 1
|
||||
7 0.5 -1
|
||||
8 1 0
|
||||
9 0.25 0
|
||||
10 0.5 0.5
|
||||
11 0.5 -0.5
|
||||
12 0.75 0
|
||||
13 -0.5 0.5
|
||||
14 -0.5 -0.5
|
||||
15 -0.75 0
|
||||
16 -1.16776 0.228134
|
||||
17 1.65174 0.239833
|
||||
18 -0.634827 0.230345
|
||||
19 -0.365731 0.231462
|
||||
20 -0.307925 0.231701
|
||||
21 0.367252 0.234503
|
||||
22 0.632199 0.235602
|
||||
23 0.881681 0.236638
|
||||
24 1.61664 -0.13454
|
||||
25 -1.26135 -0.216435
|
||||
26 0.922859 -0.154282
|
||||
27 0.669251 -0.161499
|
||||
28 0.335498 -0.170996
|
||||
29 -0.29725 -0.189001
|
||||
30 -0.345182 -0.190365
|
||||
31 -0.650474 -0.199052
|
||||
|
||||
44 0
|
||||
1 25 16
|
||||
2 29 1
|
||||
3 19 13
|
||||
4 20 19
|
||||
5 6 4
|
||||
6 4 2
|
||||
7 21 22
|
||||
8 22 23
|
||||
9 12 22
|
||||
10 5 7
|
||||
11 3 5
|
||||
12 10 21
|
||||
13 17 24
|
||||
14 23 6
|
||||
15 17 23
|
||||
16 10 22
|
||||
17 27 11
|
||||
18 28 27
|
||||
19 11 28
|
||||
20 26 7
|
||||
21 12 27
|
||||
22 26 27
|
||||
23 16 18
|
||||
24 18 15
|
||||
25 20 2
|
||||
26 13 18
|
||||
27 30 14
|
||||
28 31 30
|
||||
29 14 31
|
||||
30 1 30
|
||||
31 29 3
|
||||
32 26 8
|
||||
33 24 26
|
||||
34 18 19
|
||||
35 19 1
|
||||
36 20 1
|
||||
37 23 8
|
||||
38 9 21
|
||||
39 21 20
|
||||
40 28 9
|
||||
41 31 15
|
||||
42 30 29
|
||||
43 29 28
|
||||
44 31 25
|
||||
|
||||
3
|
||||
1 0.505223 0.0994429
|
||||
2 -0.0329387 0.0409471
|
||||
3 0.879596 0.0292479
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
16
|
||||
-0.25 0.0 -0.5 1.0
|
||||
-0.25 0.0 -0.5 -1.0
|
||||
-0.5 1.0 0.0 0.5
|
||||
-0.5 -1.0 0.0 -0.5
|
||||
0.0 0.5 0.5 1.0
|
||||
0.0 -0.5 0.5 -1.0
|
||||
0.5 1.0 1.0 0.0
|
||||
0.5 -1.0 1.0 0.0
|
||||
0.25 0.0 0.5 0.5
|
||||
0.25 0.0 0.5 -0.5
|
||||
0.5 0.5 0.75 0.0
|
||||
0.5 -0.5 0.75 0.0
|
||||
-0.25 0.0 -0.5 0.5
|
||||
-0.25 0.0 -0.5 -0.5
|
||||
-0.5 0.5 -0.75 0.0
|
||||
-0.5 -0.5 -0.75 0.0
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
# Shewchuk Triangle .poly file, produced by the CGAL::Mesh_2 package
|
||||
# Neither attributes nor boundary markers are used.
|
||||
15 2 0 0
|
||||
|
||||
1 -0.25 0
|
||||
2 -0.5 1
|
||||
3 -0.5 -1
|
||||
4 0 0.5
|
||||
5 0 -0.5
|
||||
6 0.5 1
|
||||
7 0.5 -1
|
||||
8 1 0
|
||||
9 0.25 0
|
||||
10 0.5 0.5
|
||||
11 0.5 -0.5
|
||||
12 0.75 0
|
||||
13 -0.5 0.5
|
||||
14 -0.5 -0.5
|
||||
15 -0.75 0
|
||||
|
||||
16 0
|
||||
1 15 14
|
||||
2 5 3
|
||||
3 3 1
|
||||
4 6 4
|
||||
5 4 2
|
||||
6 12 10
|
||||
7 5 7
|
||||
8 10 9
|
||||
9 7 8
|
||||
10 8 6
|
||||
11 9 11
|
||||
12 12 11
|
||||
13 13 15
|
||||
14 14 1
|
||||
15 13 1
|
||||
16 2 1
|
||||
|
||||
1
|
||||
1 0.505223 0.0994429
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Triangulation_conformer_2.h>
|
||||
|
||||
#include <CGAL/IO/File_poly.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
struct K : public CGAL::Exact_predicates_inexact_constructions_kernel {};
|
||||
typedef CGAL::Constrained_Delaunay_triangulation_2<K> CDT;
|
||||
typedef CDT::Point Point;
|
||||
typedef CDT::Vertex_handle Vertex_handle;
|
||||
|
||||
typedef CDT::size_type size_type;
|
||||
|
||||
template <class CTr>
|
||||
typename CTr::size_type number_of_constrained_edges(const CTr& tr)
|
||||
{
|
||||
typename CTr::size_type nedges = 0;
|
||||
for(typename CTr::Finite_edges_iterator eit = tr.finite_edges_begin();
|
||||
eit != tr.finite_edges_end();
|
||||
++eit)
|
||||
if(tr.is_constrained(*eit))
|
||||
++nedges;
|
||||
return nedges;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
CDT cdt;
|
||||
|
||||
// CHECK FIRST read_triangle_poly_file AND operator>> OF CDT
|
||||
|
||||
// read a poly file
|
||||
|
||||
std::cout << "Reading fish.poly...\n";
|
||||
std::ifstream poly_file("fish.poly");
|
||||
CGAL::read_triangle_poly_file(cdt, poly_file);
|
||||
|
||||
const size_type number_of_vertices_poly = cdt.number_of_vertices();
|
||||
const size_type number_of_constrained_edges_poly =
|
||||
number_of_constrained_edges(cdt);
|
||||
|
||||
std::cout << "number of vertices: " << number_of_vertices_poly
|
||||
<< "\nnumber of constrained edges: "
|
||||
<< number_of_constrained_edges_poly << "\n\n";
|
||||
|
||||
// read a CGAL file (edg file).
|
||||
|
||||
std::cout << "Reading fish.edg...\n";
|
||||
|
||||
std::ifstream edg_file("fish.edg");
|
||||
|
||||
cdt.clear();
|
||||
|
||||
size_type nedges = 0;
|
||||
edg_file >> nedges;
|
||||
for(size_type n = 0; n < nedges; ++n) {
|
||||
Point p1, p2;
|
||||
edg_file >> p1 >> p2;
|
||||
cdt.insert_constraint(p1, p2);
|
||||
}
|
||||
|
||||
const size_type number_of_vertices_edg = cdt.number_of_vertices();
|
||||
const size_type number_of_constrained_edges_edg =
|
||||
number_of_constrained_edges(cdt);
|
||||
|
||||
std::cout << "number of vertices: " << number_of_vertices_edg
|
||||
<< "\nnumber of constrained edges: "
|
||||
<< number_of_constrained_edges_edg << "\n\n";
|
||||
|
||||
|
||||
// check that numbers of constrained edges and vertices are the same
|
||||
|
||||
CGAL_assertion( number_of_constrained_edges_edg ==
|
||||
number_of_constrained_edges_poly );
|
||||
|
||||
CGAL_assertion( number_of_vertices_edg == number_of_vertices_poly );
|
||||
|
||||
// CONFORMING
|
||||
|
||||
std::cout << "Conforming...\n";
|
||||
CDT cdt2=cdt;
|
||||
|
||||
// Gabriel for cdt
|
||||
make_conforming_Gabriel_2(cdt);
|
||||
// Delaunay, then Gabriel for cdt2
|
||||
make_conforming_Delaunay_2(cdt2);
|
||||
std::cout << "Number of vertices after make_conforming_Delaunay_2: "
|
||||
<< cdt2.number_of_vertices() << "\n";
|
||||
CGAL_assertion( cdt2.number_of_vertices() == 17 );
|
||||
make_conforming_Gabriel_2(cdt2);
|
||||
std::cout << "Number of vertices after make_conforming_Gabriel_2: "
|
||||
<< cdt2.number_of_vertices() << "\n";
|
||||
CGAL_assertion( cdt2.number_of_vertices() == 29 );
|
||||
|
||||
// check that numbers of vertices are the same in cdt and cdt2
|
||||
CGAL_assertion( cdt2.number_of_vertices() ==
|
||||
cdt.number_of_vertices() );
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
// 154 515 565
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Delaunay_mesher_2.h>
|
||||
#include <CGAL/Delaunay_mesh_face_base_2.h>
|
||||
#include <CGAL/Delaunay_mesh_size_criteria_2.h>
|
||||
#include <CGAL/Delaunay_mesh_size_criteria_2.h>
|
||||
|
||||
#include <CGAL/IO/File_poly.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
struct K : public CGAL::Exact_predicates_inexact_constructions_kernel {};
|
||||
typedef CGAL::Triangulation_vertex_base_2<K> Vb;
|
||||
typedef CGAL::Delaunay_mesh_face_base_2<K> Fb;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
|
||||
typedef CGAL::Constrained_Delaunay_triangulation_2<K, Tds> CDT;
|
||||
typedef CGAL::Delaunay_mesh_size_criteria_2<CDT> Criteria;
|
||||
typedef CDT::size_type size_type;
|
||||
|
||||
typedef CDT::Point Point;
|
||||
|
||||
template <class CTr>
|
||||
typename CTr::size_type number_of_constrained_edges(const CTr& tr)
|
||||
{
|
||||
typename CTr::size_type nedges = 0;
|
||||
for(typename CTr::Finite_edges_iterator eit = tr.finite_edges_begin();
|
||||
eit != tr.finite_edges_end();
|
||||
++eit)
|
||||
if(tr.is_constrained(*eit))
|
||||
++nedges;
|
||||
return nedges;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
CDT cdt;
|
||||
|
||||
std::vector<Point> seeds;
|
||||
seeds.reserve(32);
|
||||
|
||||
std::cerr << "Reading fish-and-rectangle.poly...";
|
||||
std::ifstream poly_file("fish-and-rectangle.poly");
|
||||
CGAL::read_triangle_poly_file(cdt, poly_file, std::back_inserter(seeds));
|
||||
|
||||
const size_type inititial_number_of_vertices = cdt.number_of_vertices();
|
||||
std::cerr << " done.\nNumber of vertices: " << cdt.number_of_vertices()
|
||||
<< "\nNumber of seeds: " << seeds.size() << "\n\n";
|
||||
|
||||
std::cerr << "Saving the triangulation...\n\n";
|
||||
CDT cdt2 = cdt;
|
||||
|
||||
std::cerr << "1/ First tests:\n\n";
|
||||
|
||||
std::cerr << "Meshing the triangulation with size 0...";
|
||||
CGAL::refine_Delaunay_mesh_2(cdt,
|
||||
seeds.begin(), seeds.end(),
|
||||
Criteria());
|
||||
const size_type number_of_vertices0 = cdt.number_of_vertices();
|
||||
std::cerr << " done.\nNumber of vertices: " << cdt.number_of_vertices() << "\n\n";
|
||||
CGAL_assertion( 64 <= cdt.number_of_vertices() &&
|
||||
cdt.number_of_vertices() <= 72 );
|
||||
CGAL_assertion( seeds.size() == 3 );
|
||||
|
||||
std::cerr << "Meshing the triangulation with size 0.2...";
|
||||
CGAL::refine_Delaunay_mesh_2(cdt,
|
||||
seeds.begin(), seeds.end(),
|
||||
Criteria(0.125, 0.2));
|
||||
|
||||
std::cerr << " done.\nNumber of vertices: " << cdt.number_of_vertices() << "\n\n";
|
||||
CGAL_assertion( 180 <= cdt.number_of_vertices() &&
|
||||
cdt.number_of_vertices() <= 200 );
|
||||
|
||||
std::cerr << "Meshing the triangulation with size 0.1...";
|
||||
CGAL::refine_Delaunay_mesh_2(cdt,
|
||||
seeds.begin(), seeds.end(),
|
||||
Criteria(0.125, 0.1));
|
||||
const size_type number_of_vertices1 = cdt.number_of_vertices();
|
||||
std::cerr << " done.\nNumber of vertices: " << cdt.number_of_vertices() << "\n\n";
|
||||
CGAL_assertion( 580 <= cdt.number_of_vertices() &&
|
||||
cdt.number_of_vertices() <= 640 );
|
||||
|
||||
cdt = cdt2;
|
||||
std::cerr << "Triangulation restored.\n";
|
||||
std::cerr << "Number of vertices: " << cdt.number_of_vertices() << "\n\n";
|
||||
|
||||
std::cerr << "Meshing the triangulation with Delaunay_mesh_criteria_2<CDT>()...";
|
||||
CGAL::refine_Delaunay_mesh_2(cdt,
|
||||
seeds.begin(), seeds.end(),
|
||||
CGAL::Delaunay_mesh_criteria_2<CDT>());
|
||||
const size_type number_of_vertices0bis = cdt.number_of_vertices();
|
||||
std::cerr << " done.\nNumber of vertices: " << cdt.number_of_vertices() << "\n\n";
|
||||
|
||||
CGAL_assertion( number_of_vertices0 == number_of_vertices0bis );
|
||||
|
||||
cdt = cdt2;
|
||||
std::cerr << "Triangulation restored.\n";
|
||||
std::cerr << "Number of vertices: " << cdt.number_of_vertices() << "\n\n";
|
||||
|
||||
std::cerr << "2/ Comparaison between refine_Delaunay_mesh_2() and other"
|
||||
<< " possibilities:\n\n";
|
||||
|
||||
std::cerr << "Meshing the triangulation with size 0.1, with "
|
||||
<< "refine_Delaunay_mesh_2()...";
|
||||
CGAL::refine_Delaunay_mesh_2(cdt,
|
||||
seeds.begin(), seeds.end(),
|
||||
Criteria(0.125, 0.1));
|
||||
const size_type number_of_vertices1bis = cdt.number_of_vertices();
|
||||
std::cerr << " done.\nNumber of vertices: " << cdt.number_of_vertices()
|
||||
<< "\n\n";
|
||||
|
||||
CGAL_assertion( number_of_vertices1bis <= number_of_vertices1 );
|
||||
|
||||
cdt = cdt2;
|
||||
|
||||
std::cerr << "Meshing the triangulation with size 0.1, with "
|
||||
<< "mesher.refine_mesh()...";
|
||||
{
|
||||
CGAL::Delaunay_mesher_2<CDT, Criteria> mesher(cdt, Criteria(0.125, 0.1));
|
||||
mesher.set_seeds(seeds.begin(), seeds.end());
|
||||
mesher.refine_mesh();
|
||||
}
|
||||
const size_type number_of_vertices2 = cdt.number_of_vertices();
|
||||
std::cerr << " done.\nNumber of vertices: " << cdt.number_of_vertices()
|
||||
<< "\n\n";
|
||||
|
||||
CGAL_assertion( number_of_vertices2 == number_of_vertices1bis );
|
||||
|
||||
cdt = cdt2;
|
||||
|
||||
std::cerr << "Meshing the triangulation with size 0.1, with\n"
|
||||
<< "a loop of mesher.try_one_step_refine_mesh()...";
|
||||
size_type step = 0;
|
||||
{
|
||||
CGAL::Delaunay_mesher_2<CDT, Criteria> mesher(cdt, Criteria(0.125, 0.1));
|
||||
mesher.set_seeds(seeds.begin(), seeds.end());
|
||||
mesher.init();
|
||||
while(mesher.try_one_step_refine_mesh())
|
||||
++step;
|
||||
}
|
||||
const size_type number_of_vertices3 = cdt.number_of_vertices();
|
||||
std::cerr << " done.\nNumber of vertices: " << cdt.number_of_vertices()
|
||||
<< "\nNumber of steps: " << step << "\n\n";
|
||||
|
||||
CGAL_assertion( step + inititial_number_of_vertices >= number_of_vertices3 );
|
||||
CGAL_assertion( number_of_vertices3 == number_of_vertices2 );
|
||||
|
||||
cdt = cdt2;
|
||||
|
||||
std::cerr << "Meshing the triangulation with size 0.1, with\n"
|
||||
<< "a loop of mesher.step_by_step_refine_mesh()...";
|
||||
step = 0;
|
||||
{
|
||||
CGAL::Delaunay_mesher_2<CDT, Criteria> mesher(cdt, Criteria(0.125, 0.1));
|
||||
mesher.set_seeds(seeds.begin(), seeds.end());
|
||||
mesher.init();
|
||||
while(mesher.step_by_step_refine_mesh())
|
||||
++step;
|
||||
}
|
||||
const size_type number_of_vertices4 = cdt.number_of_vertices();
|
||||
std::cerr << " done.\nNumber of vertices: " << cdt.number_of_vertices()
|
||||
<< "\nNumber of steps: " << step << "\n\n";
|
||||
|
||||
CGAL_assertion( number_of_vertices4 == number_of_vertices2 );
|
||||
CGAL_assertion( number_of_vertices4 == step + inititial_number_of_vertices );
|
||||
}
|
||||
Loading…
Reference in New Issue