From b8d8bbe97bc1fea4fb9bea7b4e6e3bed04a1400e Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Wed, 14 Mar 2001 16:55:14 +0000 Subject: [PATCH] Initial revision --- Old_Packages/Point_set_2_tb/changes.txt | 1 + .../demo/Point_set_2_tb/GeoWin/Makefile | 38 + .../GeoWin/geowin_k_nearest_neighbors_tb.C | 89 + .../Point_set_2_tb/GeoWin/geowin_pset_2d_tb.C | 119 ++ .../demo/Point_set_2_tb/Makefile | 39 + .../demo/Point_set_2_tb/nearest_neighbor_tb.C | 102 + .../demo/Point_set_2_tb/ps_test1_cgal_tb.C | 135 ++ .../demo/Point_set_2_tb/ps_test1_tb.C | 123 ++ .../demo/Point_set_2_tb/range_search_tb.C | 113 + Old_Packages/Point_set_2_tb/description.txt | 2 + .../examples/Point_set_2_tb/makefile | 52 + .../examples/Point_set_2_tb/nearest_nb1_tr.C | 115 + .../examples/Point_set_2_tb/range_search_tr.C | 169 ++ .../Point_set_2_tb/range_search_tr_leda.C | 174 ++ .../include/CGAL/Point_set_2_tb.h | 640 ++++++ .../Triangulation_euclidean_leda_traits_2.h | 555 +++++ Old_Packages/Point_set_2_tb/maintainer | 1 + Old_Packages/Point_set_2_tb/version | 2 + Packages/Point_set_2/changes.txt | 62 + .../demo/Point_set_2/GeoWin/Makefile | 38 + .../GeoWin/geowin_k_nearest_neighbors.C | 111 + .../demo/Point_set_2/GeoWin/geowin_pset_2d.C | 120 ++ .../Point_set_2/demo/Point_set_2/Makefile | 53 + Packages/Point_set_2/demo/Point_set_2/README | 14 + .../demo/Point_set_2/locate_test.C | 80 + .../demo/Point_set_2/locate_test_hm.C | 80 + .../demo/Point_set_2/nearest_neighbor.C | 100 + .../Point_set_2/demo/Point_set_2/ps_test1.C | 111 + .../demo/Point_set_2/ps_test1_cgal.C | 131 ++ .../demo/Point_set_2/range_search.C | 115 + .../demo/Point_set_2/range_search_hm.C | 115 + .../Point_set_2/demo/Point_set_2/rs_test.C | 84 + Packages/Point_set_2/description.txt | 1 + .../doc_tex/Point_set_2/Point_set_2.tex | 374 ++++ .../Point_set_2_ref/Point_set_2.tex | 290 +++ .../Point_set_2_ref/Point_set_traits.tex | 114 + .../Point_set_2/Point_set_2_ref/cgal.bib | 17 + .../Point_set_2/Point_set_2_ref/intro.tex | 26 + .../Point_set_2/Point_set_2_ref/main.tex | 15 + .../point_set_leda_float_traits_2.tex | 35 + .../point_set_leda_rat_traits_2.tex | 35 + .../Point_set_2_ref/point_set_traits_2.tex | 36 + .../Point_set_2/doc_tex/Point_set_2/cgal.bib | 17 + .../Point_set_2/doc_tex/Point_set_2/main.tex | 12 + .../doc_tex/basic/Point_set_2/Point_set_2.tex | 374 ++++ .../Point_set_2_ref/Point_set_2.tex | 290 +++ .../Point_set_2_ref/Point_set_traits.tex | 114 + .../Point_set_2/Point_set_2_ref/cgal.bib | 17 + .../Point_set_2/Point_set_2_ref/intro.tex | 26 + .../Point_set_2/Point_set_2_ref/main.tex | 15 + .../point_set_leda_float_traits_2.tex | 35 + .../point_set_leda_rat_traits_2.tex | 35 + .../Point_set_2_ref/point_set_traits_2.tex | 36 + .../doc_tex/basic/Point_set_2/cgal.bib | 17 + .../doc_tex/basic/Point_set_2/main.tex | 12 + .../Point_set_2/examples/Point_set_2/makefile | 48 + .../examples/Point_set_2/nearest_nb1.C | 121 ++ .../examples/Point_set_2/range_search.C | 175 ++ .../Point_set_2/include/CGAL/Point_set_2.h | 1870 +++++++++++++++++ .../include/CGAL/point_set_leda_traits_2.h | 296 +++ .../include/CGAL/point_set_traits_2.h | 238 +++ Packages/Point_set_2/maintainer | 1 + .../Point_set_2/test/Point_set_2/cgal_test | 67 + .../Point_set_2/test/Point_set_2/makefile | 54 + .../test/Point_set_2/nearest_nb1.C | 137 ++ .../test/Point_set_2/range_search.C | 154 ++ Packages/Point_set_2/version | 2 + Packages/Timer/changes.txt | 31 + Packages/Timer/description.txt | 1 + Packages/Timer/doc_tex/Timer/cgal.bib | 1061 ++++++++++ Packages/Timer/doc_tex/Timer/main.tex | 11 + Packages/Timer/doc_tex/Timer/timer.tex | 129 ++ Packages/Timer/doc_tex/support/Timer/cgal.bib | 1061 ++++++++++ Packages/Timer/doc_tex/support/Timer/main.tex | 11 + .../Timer/doc_tex/support/Timer/timer.tex | 129 ++ Packages/Timer/include/CGAL/Real_timer.h | 190 ++ Packages/Timer/include/CGAL/Timer.h | 128 ++ Packages/Timer/long_description.txt | 8 + Packages/Timer/test/Timer/cgal_test | 73 + Packages/Timer/test/Timer/test_timer.C | 88 + Packages/Timer/version | 2 + 81 files changed, 11712 insertions(+) create mode 100644 Old_Packages/Point_set_2_tb/changes.txt create mode 100644 Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/GeoWin/Makefile create mode 100644 Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/GeoWin/geowin_k_nearest_neighbors_tb.C create mode 100644 Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/GeoWin/geowin_pset_2d_tb.C create mode 100644 Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/Makefile create mode 100644 Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/nearest_neighbor_tb.C create mode 100644 Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/ps_test1_cgal_tb.C create mode 100644 Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/ps_test1_tb.C create mode 100644 Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/range_search_tb.C create mode 100644 Old_Packages/Point_set_2_tb/description.txt create mode 100644 Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/makefile create mode 100644 Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/nearest_nb1_tr.C create mode 100644 Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/range_search_tr.C create mode 100644 Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/range_search_tr_leda.C create mode 100644 Old_Packages/Point_set_2_tb/include/CGAL/Point_set_2_tb.h create mode 100644 Old_Packages/Point_set_2_tb/include/CGAL/Triangulation_euclidean_leda_traits_2.h create mode 100644 Old_Packages/Point_set_2_tb/maintainer create mode 100644 Old_Packages/Point_set_2_tb/version create mode 100644 Packages/Point_set_2/changes.txt create mode 100644 Packages/Point_set_2/demo/Point_set_2/GeoWin/Makefile create mode 100644 Packages/Point_set_2/demo/Point_set_2/GeoWin/geowin_k_nearest_neighbors.C create mode 100644 Packages/Point_set_2/demo/Point_set_2/GeoWin/geowin_pset_2d.C create mode 100644 Packages/Point_set_2/demo/Point_set_2/Makefile create mode 100644 Packages/Point_set_2/demo/Point_set_2/README create mode 100644 Packages/Point_set_2/demo/Point_set_2/locate_test.C create mode 100644 Packages/Point_set_2/demo/Point_set_2/locate_test_hm.C create mode 100644 Packages/Point_set_2/demo/Point_set_2/nearest_neighbor.C create mode 100644 Packages/Point_set_2/demo/Point_set_2/ps_test1.C create mode 100644 Packages/Point_set_2/demo/Point_set_2/ps_test1_cgal.C create mode 100644 Packages/Point_set_2/demo/Point_set_2/range_search.C create mode 100644 Packages/Point_set_2/demo/Point_set_2/range_search_hm.C create mode 100644 Packages/Point_set_2/demo/Point_set_2/rs_test.C create mode 100644 Packages/Point_set_2/description.txt create mode 100644 Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2.tex create mode 100644 Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/Point_set_2.tex create mode 100644 Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/Point_set_traits.tex create mode 100644 Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/cgal.bib create mode 100644 Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/intro.tex create mode 100644 Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/main.tex create mode 100644 Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/point_set_leda_float_traits_2.tex create mode 100644 Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/point_set_leda_rat_traits_2.tex create mode 100644 Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/point_set_traits_2.tex create mode 100644 Packages/Point_set_2/doc_tex/Point_set_2/cgal.bib create mode 100644 Packages/Point_set_2/doc_tex/Point_set_2/main.tex create mode 100644 Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2.tex create mode 100644 Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/Point_set_2.tex create mode 100644 Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/Point_set_traits.tex create mode 100644 Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/cgal.bib create mode 100644 Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/intro.tex create mode 100644 Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/main.tex create mode 100644 Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/point_set_leda_float_traits_2.tex create mode 100644 Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/point_set_leda_rat_traits_2.tex create mode 100644 Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/point_set_traits_2.tex create mode 100644 Packages/Point_set_2/doc_tex/basic/Point_set_2/cgal.bib create mode 100644 Packages/Point_set_2/doc_tex/basic/Point_set_2/main.tex create mode 100644 Packages/Point_set_2/examples/Point_set_2/makefile create mode 100644 Packages/Point_set_2/examples/Point_set_2/nearest_nb1.C create mode 100644 Packages/Point_set_2/examples/Point_set_2/range_search.C create mode 100644 Packages/Point_set_2/include/CGAL/Point_set_2.h create mode 100644 Packages/Point_set_2/include/CGAL/point_set_leda_traits_2.h create mode 100644 Packages/Point_set_2/include/CGAL/point_set_traits_2.h create mode 100644 Packages/Point_set_2/maintainer create mode 100755 Packages/Point_set_2/test/Point_set_2/cgal_test create mode 100644 Packages/Point_set_2/test/Point_set_2/makefile create mode 100644 Packages/Point_set_2/test/Point_set_2/nearest_nb1.C create mode 100644 Packages/Point_set_2/test/Point_set_2/range_search.C create mode 100644 Packages/Point_set_2/version create mode 100644 Packages/Timer/changes.txt create mode 100644 Packages/Timer/description.txt create mode 100644 Packages/Timer/doc_tex/Timer/cgal.bib create mode 100644 Packages/Timer/doc_tex/Timer/main.tex create mode 100644 Packages/Timer/doc_tex/Timer/timer.tex create mode 100644 Packages/Timer/doc_tex/support/Timer/cgal.bib create mode 100644 Packages/Timer/doc_tex/support/Timer/main.tex create mode 100644 Packages/Timer/doc_tex/support/Timer/timer.tex create mode 100644 Packages/Timer/include/CGAL/Real_timer.h create mode 100644 Packages/Timer/include/CGAL/Timer.h create mode 100644 Packages/Timer/long_description.txt create mode 100755 Packages/Timer/test/Timer/cgal_test create mode 100644 Packages/Timer/test/Timer/test_timer.C create mode 100644 Packages/Timer/version diff --git a/Old_Packages/Point_set_2_tb/changes.txt b/Old_Packages/Point_set_2_tb/changes.txt new file mode 100644 index 00000000000..68b7bd871ae --- /dev/null +++ b/Old_Packages/Point_set_2_tb/changes.txt @@ -0,0 +1 @@ +0.1 BETA version of the new CGAL - Delaunay triangulation based point set diff --git a/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/GeoWin/Makefile b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/GeoWin/Makefile new file mode 100644 index 00000000000..5c8776a2741 --- /dev/null +++ b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/GeoWin/Makefile @@ -0,0 +1,38 @@ +include $(CGAL_MAKEFILE) + +CC = $(CGAL_CXX) $(CGAL_WINDOW_LIBPATH) + +CGALCFLAGS = $(CGAL_CXXFLAGS) + + +CGDL = $(CGAL_GEOWIN_LDFLAGS) + +geowin_pset_2d_tb$(EXE_EXT) : geowin_pset_2d_tb$(OBJ_EXT) + $(CC) $(EXE_OPT)geowin_pset_2d_tb geowin_pset_2d_tb$(OBJ_EXT) $(CGDL) + +geowin_k_nearest_neighbors_tb$(EXE_EXT) : geowin_k_nearest_neighbors_tb$(OBJ_EXT) + $(CC) $(EXE_OPT)geowin_k_nearest_neighbors_tb geowin_k_nearest_neighbors_tb$(OBJ_EXT) $(CGDL) + + +clean : + rm -f tt *~ *.o *.obj *.exe + rm -f geowin_k_nearest_neighbors_tb geowin_pset_2d_tb + + +all: geowin_k_nearest_neighbors_tb geowin_pset_2d_tb + + +cleano : + rm -f *~ *.o + + +#---------------------------------------------------------------------# +# suffix rules +#---------------------------------------------------------------------# + +.C$(OBJ_EXT): + $(CGAL_CXX) $(CGALCFLAGS) -c $< + +.c$(OBJ_EXT): + $(CGAL_CXX) $(CGALCFLAGS) -c $< + diff --git a/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/GeoWin/geowin_k_nearest_neighbors_tb.C b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/GeoWin/geowin_k_nearest_neighbors_tb.C new file mode 100644 index 00000000000..1e88d90abf5 --- /dev/null +++ b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/GeoWin/geowin_k_nearest_neighbors_tb.C @@ -0,0 +1,89 @@ +#include + +#include +#include + +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::Triangulation_euclidean_traits_2 Gt; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_default_data_structure_2 Tds; + +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2_tb::Edge Edge; +typedef CGAL::Point_set_2_tb::Edge_iterator Edge_iterator; +typedef CGAL::Point_set_2_tb::Vertex_handle Vertex_handle; +typedef CGAL::Point_set_2_tb::Vertex Vertex; + + +CGAL::Point_set_2_tb PST; +int k; + +class construct_pointset : public geowin_update >,std::list > > +{ +public: + void update(const std::list >& Lin, std::list >& Lout) + { + PST.init(Lin.begin(),Lin.end()); + Lout.clear(); + PST.segments(std::back_inserter(Lout)); + } +}; + + +class nearest_neighbors : public geowin_update >, std::list > > +{ +public: + void update(const std::list >& Lin, std::list >& Lout) + { + Lout.clear(); + std::list >::const_iterator it = Lin.begin(); + std::list output; + std::list::const_iterator pit; + + for (; it != Lin.end(); it++){ + PST.nearest_neighbors(*it, k, std::back_inserter(output)); + } + for (pit=output.begin(); pit != output.end(); pit++){ + Lout.push_back(CGALCircle(PST.pos(*pit),2.0)); + } + } +}; + +int main() +{ + geowin_init_default_type((std::list >*)0, leda_string("CGALPointlist")); + + std::cout << "Find the k nearest neighbors of every point in scene 2.\n"; + std::cout << "k:"; std::cin >> k; + + GeoWin gw; + + std::list > Lp; + geo_scene sc1 = gw.new_scene(Lp); + + std::list > Lother; + geo_scene sc2 = gw.new_scene(Lother); + gw.set_color(sc2,leda_blue); + + construct_pointset CP; + geo_scene sc3 = gw.new_scene(CP, sc1, leda_string("2d point set")); + gw.set_color(sc3,leda_blue); + + nearest_neighbors NN; + geo_scene sc4 = gw.new_scene(NN, sc2, leda_string("k nearest neighbors")); + gw.set_fill_color(sc4,leda_red); + gw.set_color(sc4,leda_red); + gw.set_point_style(sc4,leda_circle_point); + gw.set_line_width(sc4,4); + + gw.set_all_visible(true); + gw.add_dependence(sc1,sc4); + + gw.edit(sc1); + + return 0; +} + diff --git a/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/GeoWin/geowin_pset_2d_tb.C b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/GeoWin/geowin_pset_2d_tb.C new file mode 100644 index 00000000000..11d25a8f215 --- /dev/null +++ b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/GeoWin/geowin_pset_2d_tb.C @@ -0,0 +1,119 @@ +#include + +#include +#include + +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::Triangulation_euclidean_traits_2 Gt; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_default_data_structure_2 Tds; + +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2_tb::Edge Edge; +typedef CGAL::Point_set_2_tb::Edge_iterator Edge_iterator; +typedef CGAL::Point_set_2_tb::Vertex_handle Vertex_handle; +typedef CGAL::Point_set_2_tb::Vertex Vertex; + + +CGAL::Point_set_2_tb PST; + +class construct_pointset : public geowin_update, std::list > +{ +public: + void update(const std::list& Lin, std::list& Lout) + { + PST.init(Lin.begin(),Lin.end()); + Lout.clear(); + PST.segments(std::back_inserter(Lout)); + } +}; + + +class circle_range_search : public geowin_update, std::list > +{ + void update(const std::list& Lin, std::list& Lout) + { + Lout.clear(); + std::list::const_iterator it = Lin.begin(); + std::list output; + std::list::const_iterator pit; + + for (; it != Lin.end(); it++){ + PST.range_search(*it, std::back_inserter(output)); + } + for (pit=output.begin(); pit != output.end(); pit++){ + Lout.push_back(CGALCircle(PST.pos(*pit),2.0)); + } + } +}; + +class triangle_range_search : public geowin_update, std::list > +{ +public: + void update(const std::list& Lin, std::list& Lout) + { + Lout.clear(); + std::list::const_iterator it = Lin.begin(); + std::list output; + std::list::const_iterator pit; + + for (; it != Lin.end(); it++){ + PST.range_search((*it).vertex(0),(*it).vertex(1),(*it).vertex(2), std::back_inserter(output)); + } + for (pit=output.begin(); pit != output.end(); pit++){ + Lout.push_back(CGALCircle(PST.pos(*pit),1.0)); + } + } +}; + + +int main() +{ + geowin_init_default_type((CGALPointlist*)0, leda_string("CGALPointlist")); + geowin_init_default_type((CGALCirclelist*)0, leda_string("CGALCirclelist")); + geowin_init_default_type((CGALTrianglelist*)0, leda_string("CGALTrianglelist")); + + GeoWin gw; + + std::list Lp; + geo_scene sc1 = gw.new_scene(Lp); + + std::list Lc; + geo_scene sc_circ = gw.new_scene(Lc); + gw.set_color(sc_circ, leda_blue); + gw.set_fill_color(sc_circ, leda_invisible); + + std::list Lt; + geo_scene sc_triang = gw.new_scene(Lt); + gw.set_color(sc_triang, leda_blue2); + gw.set_line_width(sc_triang,3); + gw.set_active_line_width(sc_triang,3); + gw.set_fill_color(sc_triang, leda_invisible); + + construct_pointset CP; + gw.new_scene(CP, sc1, leda_string("2d point set")); + + circle_range_search CRS; + geo_scene sc3 = gw.new_scene(CRS, sc_circ, leda_string("circular range search")); + gw.set_color(sc3,leda_red); + gw.set_point_style(sc3, leda_circle_point); + gw.set_line_width(sc3,4); + + triangle_range_search TRS; + geo_scene sc4 = gw.new_scene(TRS, sc_triang, leda_string("triangular range search")); + gw.set_color(sc4,leda_green); + gw.set_point_style(sc4, leda_circle_point); + gw.set_line_width(sc4,4); + + gw.set_all_visible(true); + gw.add_dependence(sc1,sc3); + gw.add_dependence(sc1,sc4); + + gw.edit(sc1); + + return 1; +} + diff --git a/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/Makefile b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/Makefile new file mode 100644 index 00000000000..d1c73e3e719 --- /dev/null +++ b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/Makefile @@ -0,0 +1,39 @@ +include $(CGAL_MAKEFILE) + +CC = $(CGAL_CXX) $(CGAL_WINDOW_LIBPATH) + +CGALCFLAGS = $(CGAL_CXXFLAGS) + +CGDL = $(CGAL_WINDOW_LDFLAGS) + + +ps_test1_tb$(EXE_EXT) : ps_test1_tb$(OBJ_EXT) + $(CC) $(EXE_OPT)ps_test1_tb ps_test1_tb$(OBJ_EXT) $(CGDL) + +ps_test1_cgal_tb$(EXE_EXT) : ps_test1_cgal_tb$(OBJ_EXT) + $(CC) $(EXE_OPT)ps_test1_cgal_tb ps_test1_cgal_tb$(OBJ_EXT) $(CGDL) + +nearest_neighbor_tb$(EXE_EXT) : nearest_neighbor_tb$(OBJ_EXT) + $(CC) $(EXE_OPT)nearest_neighbor_tb nearest_neighbor_tb$(OBJ_EXT) $(CGDL) + +range_search_tb$(EXE_EXT) : range_search_tb$(OBJ_EXT) + $(CC) $(EXE_OPT)range_search_tb range_search_tb$(OBJ_EXT) $(CGDL) + +clean : + rm -f tt *~ *.o *.obj *.exe core + rm -f nearest_neighbor_tb ps_test1_cgal_tb ps_test1_tb range_search_tb + +all: nearest_neighbor_tb ps_test1_cgal_tb ps_test1_tb range_search_tb + +cleano : + rm -f *~ *.o + + +#---------------------------------------------------------------------# +# suffix rules +#---------------------------------------------------------------------# + +.C$(OBJ_EXT): + $(CGAL_CXX) $(CGALCFLAGS) $(OBJ_OPT) $< + + diff --git a/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/nearest_neighbor_tb.C b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/nearest_neighbor_tb.C new file mode 100644 index 00000000000..695f747741f --- /dev/null +++ b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/nearest_neighbor_tb.C @@ -0,0 +1,102 @@ +#include +#include +#include +#include + +#include +#include + +#include +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::Triangulation_euclidean_traits_2 Gt; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_default_data_structure_2 Tds; + +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2_tb::Edge Edge; +typedef CGAL::Point_set_2_tb::Edge_iterator Edge_iterator; +typedef CGAL::Point_set_2_tb::Vertex_handle Vertex_handle; +typedef CGAL::Point_set_2_tb::Vertex Vertex; + +leda_segment get_seg(const CGAL::Segment_2& s) +{ + CGAL::Point_2 ps=s.source(); + CGAL::Point_2 pt=s.target(); + + leda_point p1(ps.x(),ps.y()), p2(pt.x(),pt.y()); + + return leda_segment(p1, p2); +} + +void output(leda_window& W, const CGAL::Point_set_2_tb& PSet) +{ + W.clear(); + Edge e; + Edge_iterator eit = PSet.finite_edges_begin(); + + for(;eit != PSet.finite_edges_end(); eit++) { + e = *eit; + CGAL::Segment_2 s= PSet.seg(e); + W << get_seg(s); + } +} + +int main() +{ + CGAL::Point_set_2_tb PSet; + + leda_window W(600,500, leda_string("Finding nearest neighbors")); + CGAL::cgalize( W); + + W.init(-500,500,-400); + W.display(100,100); + + CGAL::Point_2 actual; + int i; + + for (i=0; i<25; i++){ + W >> actual; + PSet.insert(actual); + output(W,PSet); + } + + // nearest neighbor ... + for (i=0; i<5; i++){ + W >> actual; + Vertex_handle v = PSet.nearest_neighbor(actual); + + CGAL::Segment_2 my_seg(actual,PSet.pos(v)); + + W << CGAL::RED << PSet.pos(v) << CGAL::BLACK; + W << CGAL::BLUE << my_seg << CGAL::BLACK; + } + + // k nearest neighbors ... + std::list L; + std::list::const_iterator it; + + for (i=0; i<5; i++){ + L.clear(); + W >> actual; + PSet.nearest_neighbors(actual,5, std::back_inserter(L)); + std::cout << "actual point: " << actual << "\n"; + + W.clear(); + output(W,PSet); + W << CGAL::RED << actual << CGAL::BLACK; + + for (it=L.begin();it != L.end(); it++){ + W << CGAL::GREEN << PSet.pos(*it) << CGAL::BLACK; + std::cout << PSet.pos(*it) << "\n"; + } + std::cout << "\n"; + } + + W.read_mouse(); + + return 1; +} + diff --git a/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/ps_test1_cgal_tb.C b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/ps_test1_cgal_tb.C new file mode 100644 index 00000000000..150c7a1fa7a --- /dev/null +++ b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/ps_test1_cgal_tb.C @@ -0,0 +1,135 @@ +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +//typedef CGAL::Cartesian REP; +typedef CGAL::Cartesian REP; +typedef CGAL::Triangulation_euclidean_traits_2 Gt; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_default_data_structure_2 Tds; + +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2_tb::Edge Edge; +typedef CGAL::Point_set_2_tb::Edge_iterator Edge_iterator; +typedef CGAL::Point_set_2_tb::Vertex_handle Vertex_handle; +typedef CGAL::Point_set_2_tb::Vertex Vertex; + +leda_segment get_seg(const CGAL::Segment_2& s) +{ + CGAL::Point_2 ps=s.source(); + CGAL::Point_2 pt=s.target(); + + leda_rat_point p1(ps.x(),ps.y()), p2(pt.x(),pt.y()); + + return leda_segment(p1.to_float(), p2.to_float()); +} + +void output(leda_window& W, const CGAL::Point_set_2_tb& PSet) +{ + W.clear(); + Edge e; + Edge_iterator eit = PSet.finite_edges_begin(); + + for(;eit != PSet.finite_edges_end(); eit++) { + e = *eit; + CGAL::Segment_2 s= PSet.seg(e); + W << get_seg(s); + } +} + + +int main() +{ + int i; + CGAL::Point_set_2_tb PSR_rat; + + leda_window W(600,500); + CGAL::cgalize( W); + + W.init(-500,500,-400); + W.display(100,100); + + output(W,PSR_rat); + + for (i=0; i<25; i++) { + CGAL::Point_2 pnew; + W >> pnew; + PSR_rat.insert(pnew); + output(W,PSR_rat); + } + + for (i=0; i<2; i++) { + CGAL::Point_2 pnew; + W >> pnew; + Vertex_handle v = PSR_rat.nearest_neighbor(pnew); + PSR_rat.del(v); + output(W,PSR_rat); + } + + std::cout << "circular range search !\n"; + + CGAL::Circle_2 rc; + W >> rc; + + std::list LV; + std::list::const_iterator vit; + + PSR_rat.range_search(rc,std::back_inserter(LV)); + + W.set_color(leda_red); + for(vit=LV.begin(); vit!=LV.end(); vit++){ + W << PSR_rat.pos(*vit); + } + W.set_color(leda_black); + + std::cout << LV.size() << "\n"; + + std::cout << "triangular range search !\n"; + + CGAL::Point_2 pt1,pt2,pt3,pt4; + W >> pt1; + W >> pt2; + W >> pt3; + + std::list outlist; + + PSR_rat.range_search(pt1,pt2,pt3,std::back_inserter(outlist)); + W.set_color(leda_green); + for(vit=outlist.begin(); vit!=outlist.end(); vit++){ + W << PSR_rat.pos(*vit); + } + W.set_color(leda_black); + + std::cout << outlist.size() << "\n"; + + outlist.clear(); + + std::cout << "rectangular range search !\n"; + W >> pt1; W >> pt3; + + pt2 = CGAL::Point_2(pt3.x(),pt1.y()); + pt4 = CGAL::Point_2(pt1.x(),pt3.y()); + + PSR_rat.range_search(pt1,pt2,pt3,pt4,std::back_inserter(outlist)); + W.set_color(leda_yellow); + for(vit=outlist.begin(); vit!=outlist.end(); vit++){ + W << PSR_rat.pos(*vit); + } + W.set_color(leda_black); + std::cout << outlist.size() << "\n"; + + W.read_mouse(); + + return 1; +} + diff --git a/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/ps_test1_tb.C b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/ps_test1_tb.C new file mode 100644 index 00000000000..1aadf35f6b4 --- /dev/null +++ b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/ps_test1_tb.C @@ -0,0 +1,123 @@ +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +//typedef CGAL::Triangulation_euclidean_leda_rat_traits_2 Gt; +typedef CGAL::Triangulation_euclidean_leda_float_traits_2 Gt; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_default_data_structure_2 Tds; + +//typedef CGAL::point_set_leda_rat_traits_2 TRAITS; +typedef CGAL::point_set_leda_float_traits_2 TRAITS; +typedef CGAL::Point_set_2_tb::Edge Edge; +typedef CGAL::Point_set_2_tb::Edge_iterator Edge_iterator; +typedef CGAL::Point_set_2_tb::Vertex_handle Vertex_handle; +typedef CGAL::Point_set_2_tb::Vertex Vertex; +typedef Gt::Segment_2 Segment; +typedef Gt::Point_2 Point; +//typedef leda_rat_circle Circle; +typedef leda_circle Circle; + + +void output(leda_window& W, const CGAL::Point_set_2_tb& PSet) +{ + W.clear(); + Edge e; + Edge_iterator eit = PSet.finite_edges_begin(); + + for(;eit != PSet.finite_edges_end(); eit++) { + e = *eit; + Segment s= PSet.seg(e); + W << s.to_float(); + } +} + +int main() +{ + int i; + CGAL::Point_set_2_tb PSR_rat; + leda_window W(500,400); + W.init(-500,500,-400); + W.display(); + + for (i=0; i<30; i++) { + Point pnew; + W >> pnew; + PSR_rat.insert(pnew); + output(W,PSR_rat); + } + + for (i=0; i<3; i++) { + Point pnew; + W >> pnew; + Vertex_handle v = PSR_rat.nearest_neighbor(pnew); + PSR_rat.del(v); + output(W,PSR_rat); + } + + Circle rc; + W >> rc; W << rc; + +#if (__LEDA__ >= 400) + W.set_point_style(leda_disc_point); +#endif + + std::list LV; + std::list::const_iterator vit; + + PSR_rat.range_search(rc,std::back_inserter(LV)); + + W.set_color(leda_red); + for(vit=LV.begin(); vit!=LV.end(); vit++){ + W << PSR_rat.pos(*vit); + } + W.set_color(leda_black); + + std::cout << "circular range_search - found " << LV.size() << " vertices!\n"; + + std::cout << "range search for triangle !\n"; + Point pt1,pt2,pt3,pt4; + W >> pt1; W << pt1; + W >> pt2; W << pt2; + W >> pt3; W << pt3; + + LV.clear(); + PSR_rat.range_search(pt1,pt2,pt3,std::back_inserter(LV)); + std::list::const_iterator it; + W.set_color(leda_green); + + for (it=LV.begin();it != LV.end(); it++) + W << PSR_rat.pos(*it); + + std::cout << "triangular range_search - found " << LV.size() << " vertices!\n"; + + LV.clear(); + + W >> pt1; W << pt1; + W >> pt3; W << pt3; + + pt2 = Point(pt3.xcoord(),pt1.ycoord()); + pt4 = Point(pt1.xcoord(),pt3.ycoord()); + + W.set_color(leda_orange); + PSR_rat.range_search(pt1,pt2,pt3,pt4,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + W << PSR_rat.pos(*it); + + std::cout << "rectangular range_search - found " << LV.size() << " vertices!\n"; + + W.read_mouse(); + return 0; +} + diff --git a/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/range_search_tb.C b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/range_search_tb.C new file mode 100644 index 00000000000..c9e811fefc1 --- /dev/null +++ b/Old_Packages/Point_set_2_tb/demo/Point_set_2_tb/range_search_tb.C @@ -0,0 +1,113 @@ +#include +#include +#include +#include + +#include +#include + +#include +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::Triangulation_euclidean_traits_2 Gt; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_default_data_structure_2 Tds; + + +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2_tb::Edge Edge; +typedef CGAL::Point_set_2_tb::Edge_iterator Edge_iterator; +typedef CGAL::Point_set_2_tb::Vertex_handle Vertex_handle; +typedef CGAL::Point_set_2_tb::Vertex Vertex; + +leda_segment get_seg(const CGAL::Segment_2& s) +{ + CGAL::Point_2 ps=s.source(); + CGAL::Point_2 pt=s.target(); + + leda_point p1(ps.x(),ps.y()), p2(pt.x(),pt.y()); + + return leda_segment(p1, p2); +} + +void output(leda_window& W, const CGAL::Point_set_2_tb& PSet) +{ + W.clear(); + Edge e; + Edge_iterator eit = PSet.finite_edges_begin(); + + for(;eit != PSet.finite_edges_end(); eit++) { + e = *eit; + CGAL::Segment_2 s= PSet.seg(e); + W << get_seg(s); + } +} + +int main() +{ + int i; + CGAL::Point_set_2_tb PSet; + CGAL::Point_2 pnew; + leda_window W(600,500,leda_string("Range searches")); + CGAL::cgalize( W); + + W.init(-500,500,-400); + W.display(100,100); + + for (i=0; i<30; i++) { + W >> pnew; + PSet.insert(pnew); + output(W,PSet); + } + + + for (i=0; i<5; i++) { + W >> pnew; + Vertex_handle v = PSet.nearest_neighbor(pnew); + std::cout << "delete!\n"; std::cout.flush(); + PSet.del(v); + output(W,PSet); + } + + + std::cout << "range search for circle !\n"; + CGAL::Circle_2 rc; + W >> rc; + + std::list LV; + PSet.range_search(rc,std::back_inserter(LV)); + + std::list::const_iterator it; + for (it=LV.begin();it != LV.end(); it++) + W << CGAL::GREEN << PSet.pos(*it) << CGAL::BLACK; + + std::cout << "range search for triangle !\n"; + CGAL::Point_2 pt1,pt2,pt3,pt4; + W >> pt1; + W >> pt2; + W >> pt3; + + LV.clear(); + PSet.range_search(pt1,pt2,pt3,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + W << CGAL::BLUE << PSet.pos(*it) << CGAL::BLACK; + + LV.clear(); + + std::cout << "range search for iso rectangle !\n"; + W >> pt1; // lower left + W >> pt3; // upper right + pt2 = CGAL::Point_2(pt3.x(),pt1.y()); + pt4 = CGAL::Point_2(pt1.x(),pt3.y()); + + PSet.range_search(pt1,pt2,pt3,pt4,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + W << CGAL::RED << PSet.pos(*it) << CGAL::BLACK; + + W.read_mouse(); + + return 1; +} + diff --git a/Old_Packages/Point_set_2_tb/description.txt b/Old_Packages/Point_set_2_tb/description.txt new file mode 100644 index 00000000000..e192f6be83d --- /dev/null +++ b/Old_Packages/Point_set_2_tb/description.txt @@ -0,0 +1,2 @@ +2d Point set data type - CGAL triangulation based version + diff --git a/Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/makefile b/Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/makefile new file mode 100644 index 00000000000..0c72134e930 --- /dev/null +++ b/Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/makefile @@ -0,0 +1,52 @@ +include $(CGAL_MAKEFILE) + +#---------------------------------------------------------------------# +# compiler flags +#---------------------------------------------------------------------# + +CXXFLAGS = \ + $(CGAL_CXXFLAGS) + + + +#---------------------------------------------------------------------# +# linker flags +#---------------------------------------------------------------------# + +LIBPATH = \ + $(TESTSUITE_LIBPATH) \ + $(CGAL_LIBPATH) + +LDFLAGS = \ + $(TESTSUITE_LDFLAGS) \ + $(CGAL_LDFLAGS) + + +#---------------------------------------------------------------------# +# target entries +#---------------------------------------------------------------------# + +all: \ + range_search_tr \ + range_search_tr_leda \ + nearest_nb1_tr + +range_search_tr$(EXE_EXT) : range_search_tr$(OBJ_EXT) + $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)range_search_tr range_search_tr$(OBJ_EXT) $(LDFLAGS) + +range_search_tr_leda$(EXE_EXT) : range_search_tr_leda$(OBJ_EXT) + $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)range_search_tr_leda range_search_tr_leda$(OBJ_EXT) $(LDFLAGS) + +nearest_nb1_tr$(EXE_EXT) : nearest_nb1_tr$(OBJ_EXT) + $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)nearest_nb1_tr nearest_nb1_tr$(OBJ_EXT) $(LDFLAGS) + +clean: + rm -f range_search_tr nearest_nb1_tr range_search_tr_leda *$(OBJ_EXT) *.obj *.exe core + +#---------------------------------------------------------------------# +# suffix rules +#---------------------------------------------------------------------# + +.C$(OBJ_EXT): + $(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $< + diff --git a/Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/nearest_nb1_tr.C b/Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/nearest_nb1_tr.C new file mode 100644 index 00000000000..c96d43ea165 --- /dev/null +++ b/Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/nearest_nb1_tr.C @@ -0,0 +1,115 @@ + + +#include + +#if !defined(CGAL_USE_LEDA) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + +#include + +#include +#include +#include + +#include +#include + +#include +#include + +using namespace CGAL; +using namespace std; + +typedef Cartesian REP; +typedef CGAL::Triangulation_euclidean_traits_2 Gt; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_default_data_structure_2 Tds; + + +typedef point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2_tb::Edge Edge; +typedef CGAL::Point_set_2_tb::Edge_iterator Edge_iterator; +typedef CGAL::Point_set_2_tb::Vertex_handle Vertex_handle; +typedef CGAL::Point_set_2_tb::Vertex Vertex; + + +Point_set_2_tb PSet; + + +Point_2 ar1[5]; + +int check1(std::list L) +{ + cout << "check 1!\n"; + if (L.size() != 5) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar1[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int main() +{ + std::list > Lr; + + int w1,w2; + + Point_2 p1(12,14,1); + Point_2 p2(-12,14,1); + Point_2 p3(2,11,1); + Point_2 p4(5,6,1); + Point_2 p5(67,38,10); + Point_2 p6(11,20,1); + Point_2 p7(-5,6,1); + Point_2 p8(12,0,1); + Point_2 p9(4,31,1); + Point_2 p10(-10,-10,1); + + Lr.push_back(p1); Lr.push_back(p2); Lr.push_back(p3); + Lr.push_back(p4); Lr.push_back(p5); Lr.push_back(p6); + Lr.push_back(p7); Lr.push_back(p8); Lr.push_back(p9); + Lr.push_back(p10); + + PSet.init(Lr.begin(),Lr.end()); + + // init + ar1[0]=p4; ar1[1]=p5; ar1[2]=p3; ar1[3]=p7; ar1[4]=p8; + + Point_2 actual(30,45,10); + + // nearest neighbor ... + Vertex_handle v = PSet.nearest_neighbor(actual); + cout << "Nearest neighbor:" << PSet.pos(v) << "\n"; + + if (PSet.pos(v) == p4) w1=0; else w1=1; + + // k nearest neighbors ... + std::list L; + std::list::const_iterator it; + + PSet.nearest_neighbors(actual,5,back_inserter(L)); + cout << "actual point: " << actual << "\n"; + + for (it=L.begin();it != L.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w2=check1(L); + + if (w1==0 && w2==0) return 0; + else return 1; +} + +#endif diff --git a/Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/range_search_tr.C b/Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/range_search_tr.C new file mode 100644 index 00000000000..8e933076eaf --- /dev/null +++ b/Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/range_search_tr.C @@ -0,0 +1,169 @@ + +#include + +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 400) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + + +#include + +#include +#include +#include + +#include +#include + +#include +#include + +using namespace CGAL; +using namespace std; + +typedef Cartesian REP; +typedef CGAL::Triangulation_euclidean_traits_2 Gt; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_default_data_structure_2 Tds; + + +typedef point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2_tb::Edge Edge; +typedef CGAL::Point_set_2_tb::Edge_iterator Edge_iterator; +typedef CGAL::Point_set_2_tb::Vertex_handle Vertex_handle; +typedef CGAL::Point_set_2_tb::Vertex Vertex; + + +Point_set_2_tb PSet; + +Point_2 ar1[6]; +Point_2 ar2[3]; +Point_2 ar3[3]; + +int check1(std::list L) +{ + cout << "check 1!\n"; + if (L.size() != 6) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar1[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int check2(std::list L) +{ + cout << "check 2!\n"; + if (L.size() != 3) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar2[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int check3(std::list L) +{ + cout << "check 3!\n"; + if (L.size() != 3) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar3[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int main() +{ + Point_2 pnew(120,62,10); + + int w1,w2,w3; + + std::list > Lr; + + Point_2 p1(12,14,1); + Point_2 p2(-12,14,1); + Point_2 p3(2,11,1); + Point_2 p4(5,6,1); + Point_2 p5(67,38,10); + Point_2 p6(11,20,1); + Point_2 p7(-5,6,1); + Point_2 p8(12,0,1); + Point_2 p9(4,31,1); + Point_2 p10(-10,-10,1); + + // init + ar1[0]=p1; ar1[1]=p6; ar1[2]=p3; ar1[3]=p4; ar1[4]=p5; ar1[5]=pnew; + ar2[0]=p2; ar2[1]=p3; ar2[2]=p1; + ar3[0]=p7; ar3[1]=p10; ar3[2]=p3; + + Lr.push_back(p1); Lr.push_back(p2); Lr.push_back(p3); + Lr.push_back(p4); Lr.push_back(p5); Lr.push_back(p6); + Lr.push_back(p7); Lr.push_back(p8); Lr.push_back(p9); + Lr.push_back(p10); + + PSet.init(Lr.begin(),Lr.end()); + + cout << "insert!\n"; cout.flush(); + PSet.insert(pnew); + + + cout << "range search for circle !\n"; + Circle_2 rc(p5,p6); + + std::list LV; + PSet.range_search(rc,back_inserter(LV)); + + std::list::const_iterator it; + for (it=LV.begin();it != LV.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w1 = check1(LV); + + cout << "range search for triangle !\n"; + + LV.clear(); + PSet.range_search(p1,p2,p3,back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w2 = check2(LV); + LV.clear(); + + cout << "range search for iso rectangle !\n"; + Point_2 pt1=p10; // lower left + Point_2 pt3=p3; // upper right + + Point_2 pt2 = Point_2(pt3.x(),pt1.y()); + Point_2 pt4 = Point_2(pt1.x(),pt3.y()); + + PSet.range_search(pt1,pt2,pt3,pt4,back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w3 = check3(LV); + + if (w1==0 && w2==0 && w3==0) return 0; + else return 1; +} + +#endif diff --git a/Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/range_search_tr_leda.C b/Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/range_search_tr_leda.C new file mode 100644 index 00000000000..bb628bf0fb4 --- /dev/null +++ b/Old_Packages/Point_set_2_tb/examples/Point_set_2_tb/range_search_tr_leda.C @@ -0,0 +1,174 @@ + +#include + +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 400) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + + +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include + +using namespace CGAL; +using namespace std; + +//typedef CGAL::Triangulation_euclidean_leda_rat_traits_2 Gt; +typedef CGAL::Triangulation_euclidean_leda_float_traits_2 Gt; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_default_data_structure_2 Tds; + +//typedef CGAL::point_set_leda_rat_traits_2 TRAITS; +typedef CGAL::point_set_leda_float_traits_2 TRAITS; +typedef CGAL::Point_set_2_tb::Edge Edge; +typedef CGAL::Point_set_2_tb::Edge_iterator Edge_iterator; +typedef CGAL::Point_set_2_tb::Vertex_handle Vertex_handle; +typedef CGAL::Point_set_2_tb::Vertex Vertex; +typedef Gt::Segment_2 Segment; +typedef Gt::Point_2 Point; +//typedef leda_rat_circle Circle; +typedef leda_circle Circle; + + +Point_set_2_tb PSet; + +Point ar1[6]; +Point ar2[3]; +Point ar3[3]; + +int check1(std::list L) +{ + cout << "check 1!\n"; + if (L.size() != 6) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar1[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int check2(std::list L) +{ + cout << "check 2!\n"; + if (L.size() != 3) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar2[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int check3(std::list L) +{ + cout << "check 3!\n"; + if (L.size() != 3) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar3[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int main() +{ + Point pnew(120,62,10); + + int w1,w2,w3; + + std::list Lr; + + Point p1(12,14,1); + Point p2(-12,14,1); + Point p3(2,11,1); + Point p4(5,6,1); + Point p5(67,38,10); + Point p6(11,20,1); + Point p7(-5,6,1); + Point p8(12,0,1); + Point p9(4,31,1); + Point p10(-10,-10,1); + + // init + ar1[0]=p1; ar1[1]=p6; ar1[2]=p3; ar1[3]=p4; ar1[4]=p5; ar1[5]=pnew; + ar2[0]=p2; ar2[1]=p3; ar2[2]=p1; + ar3[0]=p7; ar3[1]=p10; ar3[2]=p3; + + Lr.push_back(p1); Lr.push_back(p2); Lr.push_back(p3); + Lr.push_back(p4); Lr.push_back(p5); Lr.push_back(p6); + Lr.push_back(p7); Lr.push_back(p8); Lr.push_back(p9); + Lr.push_back(p10); + + PSet.init(Lr.begin(),Lr.end()); + + cout << "insert!\n"; cout.flush(); + PSet.insert(pnew); + + + cout << "range search for circle !\n"; + Circle rc(p5,p6); + + std::list LV; + PSet.range_search(rc,back_inserter(LV)); + + std::list::const_iterator it; + for (it=LV.begin();it != LV.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w1 = check1(LV); + + cout << "range search for triangle !\n"; + + LV.clear(); + PSet.range_search(p1,p2,p3,back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w2 = check2(LV); + LV.clear(); + + cout << "range search for iso rectangle !\n"; + Point pt1=p10; // lower left + Point pt3=p3; // upper right + + Point pt2 = Point(pt3.xcoord(),pt1.ycoord()); + Point pt4 = Point(pt1.xcoord(),pt3.ycoord()); + + PSet.range_search(pt1,pt2,pt3,pt4,back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w3 = check3(LV); + + if (w1==0 && w2==0 && w3==0) return 0; + else return 1; +} + +#endif diff --git a/Old_Packages/Point_set_2_tb/include/CGAL/Point_set_2_tb.h b/Old_Packages/Point_set_2_tb/include/CGAL/Point_set_2_tb.h new file mode 100644 index 00000000000..524bbcf690a --- /dev/null +++ b/Old_Packages/Point_set_2_tb/include/CGAL/Point_set_2_tb.h @@ -0,0 +1,640 @@ +// ====================================================================== +// +// Copyright (c) 1999 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------- +// +// release : +// release_date : 2000, December 15 +// +// file : include/CGAL/Point_set_2_tb.h +// package : Point_set_2_tb (0.1) +// maintainer : Matthias Baesken +// revision : 0.1 +// revision_date : 15 December 2000 +// author(s) : Matthias Baesken +// +// coordinator : Matthias Baesken, Trier () +// ====================================================================== + +#ifndef CGAL_POINT_SET_2_TB_H +#define CGAL_POINT_SET_2_TB_H + +#include +#include +#include +#include + +#if defined(USE_LEDA_CONTAINERS) +#include +#endif + +#if !defined(USE_LEDA_CONTAINERS) +#include +#include +#else +#include +#endif + +#include + +#include + + +CGAL_BEGIN_NAMESPACE + +#if !defined(USE_LEDA_CONTAINERS) +// compare function objects for the priority queues used in nearest neighbor search +template +class compare_vertices { + public: + std::map > *pmap; + + compare_vertices(std::map > *p){ pmap=p; } + + bool operator()(VP e1, VP e2) + // get the priorities from the map and return result of comparison ... + { NT& v1 = (*pmap)[e1]; + NT& v2 = (*pmap)[e2]; + return (v1 > v2); + } +}; +#endif + + +template +class Point_set_2_tb : public Delaunay_triangulation_2 +{ + +public: + typedef Gt Geom_traits; + typedef typename Geom_traits::Point_2 Point; + typedef typename Geom_traits::Ray_2 Ray; + typedef typename Geom_traits::Line_2 Line; + + typedef Triangulation_2 Triangulation; + typedef typename Triangulation::Locate_type Locate_type; + typedef typename Triangulation::Face_handle Face_handle; + typedef typename Triangulation::Vertex_handle Vertex_handle; + typedef typename Triangulation::Edge Edge; + typedef typename Triangulation::Vertex Vertex; + typedef typename Triangulation::Face Face; + typedef typename Triangulation::Edge_circulator Edge_circulator; + typedef typename Triangulation::Finite_edges_iterator Finite_edges_iterator; + typedef typename Triangulation::Vertex_iterator Vertex_iterator; + typedef typename Triangulation::Edge_iterator Edge_iterator; + + typedef typename Str::FT Numb_type; + typedef typename Str::Circle Circle; + typedef typename Str::Segment Segment; + + //functionality on these types... + typedef typename Str::Compare_xy_2 Comparepoints; + typedef typename Str::Compare_dist_2 Comparedist; + typedef typename Str::Orientation Orientation_2; + typedef typename Str::Side_of_oriented_circle_2 Sideofcircle; + typedef typename Str::Side_of_halfspace_2 Sideofhalfspace; + typedef typename Str::Segment_has_on_2 Segmentcontains; + typedef typename Str::Squared_distance Sqrdist; + typedef typename Str::Squared_distance_to_line Linesqrdist; + typedef typename Str::Circle_bounded_side_2 Circleptori; + typedef typename Str::Circle_center_2 Circlecenter; + + //constructors... + typedef typename Str::Construct_circle_2 Createcircle_3p; + typedef typename Str::Construct_segment_2 Createsegment_2p; + typedef typename Str::Construct_line_2 Createline_2p; + + Str traits; + + Comparepoints tr_comparepoints; + Comparedist tr_comparedist; + Orientation_2 tr_orientation; + Sideofcircle tr_so_circle; + Sideofhalfspace tr_so_hp; + Segmentcontains tr_seg_contains; + Sqrdist tr_sqrdist; + Linesqrdist tr_linesqrdist; + Circleptori tr_circleptori; + Circlecenter tr_circlecenter; + + //constructors... + Createcircle_3p tr_createcircle_3p; + Createsegment_2p tr_createsegment_2p; + Createline_2p tr_createline_2p; + + + Point_set_2_tb() + { + init_vertex_marks(); + } + + + Point_set_2_tb(const std::list& S) + { + init_vertex_marks(); + init(S); + } + + template + Point_set_2_tb(InputIterator first, InputIterator last) + { + init_vertex_marks(); + init(first,last); + } + + ~Point_set_2_tb() {} + + + void init(const std::list& L0) + { + clear(); + insert(L0.begin(), L0.end()); + init_vertex_marks(); + } + + + template + void init(InputIterator first, InputIterator last) + { + clear(); + insert(first,last); + init_vertex_marks(); + } + + + std::list points() const + { std::list L; + Vertex_iterator vit = finite_vertices_begin(); + for(;vit != finite_vertices_end(); vit++) { + Vertex v = *vit; + L.push_back(v.point()); + } + return L; + } + + template + OutputIterator points(OutputIterator out) + { + Vertex_iterator vit = finite_vertices_begin(); + for (; vit != finite_vertices_end(); vit++) { *out= (*vit).point(); out++; } + return out; + } + + template + OutputIterator segments(OutputIterator out) + { + Edge_iterator eit = finite_edges_begin(); + for (; eit != finite_edges_end(); eit++) { + *out= segment(eit); + out++; + } + return out; + } + + template + OutputIterator vertices(OutputIterator res) + // return vertex handles ... + { + Vertex_iterator vit = finite_vertices_begin(); + for (; vit != finite_vertices_end(); vit++) { *res= (*vit).handle(); res++; } + return res; + } + + template + OutputIterator edges(OutputIterator out) + { + Edge_iterator eit = finite_edges_begin(); + for (; eit != finite_edges_end(); eit++) { + *out = *eit; + } + return out; + } + + // ----------------------------------------------------- + // d_face_cycle_succ and d_face_cycle_pred removed ... + // ----------------------------------------------------- + + + bool empty() { return number_of_vertices() == 0; } + + bool is_empty() { return number_of_vertices() == 0; } + + // ------------------------------------------------------------------------- + // locate removed; use the locate - operations inherited from triangulation + // ------------------------------------------------------------------------- + + // Vertex -> Vertex_handle ... + Vertex_handle lookup(Point p) const + { + if (number_of_vertices() == 0) return NULL; + + // locate ... + Locate_type lt; + int li; + Face_handle fh = locate(p,lt,li); + + if (lt == VERTEX){ + Face f = *fh; + return f.vertex(li); + } + else return NULL; + } + + + void del(Vertex_handle v) + { + remove(v); + } + + + void del(Point p) + { Vertex_handle v = lookup(p); + if ( v != NULL ) del(v); + } + + + Vertex_handle nearest_neighbor(Point p) + { + if (number_of_vertices() == 0) return NULL; + return nearest_vertex(p); + } + + + Vertex_handle nearest_neighbor(Vertex_handle v) const + { + if (number_of_vertices() <= 1) return NULL; + Point p = v->point(); + + Vertex_circulator vc = incident_vertices(v); + Vertex_circulator start =vc; + + Vertex_handle min_v = (*vc).handle(); + if (is_infinite(min_v)){ + vc++; + min_v = (*vc).handle(); + } + + Vertex_handle act; + + // go through the vertices ... + do { + act = vc->handle(); + + if (! is_infinite(act)) { + if ( tr_comparedist(p,act->point(), min_v->point()) == SMALLER ) min_v = act; + } + + vc++; + } while (vc != start); + + return min_v; + } + + template + OutputIterator nearest_neighbors(Point p, int k, OutputIterator res) + { + int n = number_of_vertices(); + + if ( k <= 0 ) return res; + if ( n <= k ) { // return all finite vertices ... + return vertices(res); + } + + // insert p, if nesessary + + Vertex_handle vh = lookup(p); + bool old_node = true; + + // we have to add a new vertex ... + if (vh == NULL){ + vh = insert(p); + old_node = false; + k++; + } + + std::list res_list; + nearest_neighbors(vh, k, res_list); + + if ( !old_node ) + { + res_list.pop_front(); + remove(vh); + } + + std::list::const_iterator it = res_list.begin(); + + for (; it != res_list.end(); it++) { *res= *it; res++; } + + return res; + } + + template + OutputIterator nearest_neighbors(Vertex_handle v, int k,OutputIterator res) + { + int n = number_of_vertices(); + + if ( k <= 0 ) return res; + if ( n <= k ) { // return all (finite) vertices ... + return vertices(res); + } + + std::list res_list; + nearest_neighbors(v, k, res_list); + } + + void nearest_neighbors(Vertex_handle v, int k, std::list& res) + { + int n = number_of_vertices(); + + if ( k <= 0 ) return; + if ( n <= k ) { vertices(std::back_inserter(res)); return; } + + Point p = v->point(); + + // "unmark" the vertices ... + init_dfs(); + +#if defined(USE_LEDA_CONTAINERS) + leda_p_queue PQ; +#else + std::map > priority_number; // here we save the priorities ... + compare_vertices comp(& priority_number); // comparison object ... + priority_queue, CGAL::compare_vertices > PQ(comp); +#endif + +#if defined(USE_LEDA_CONTAINERS) + PQ.insert(0,v.ptr()); +#else + priority_number[v.ptr()] = 0; + PQ.push(v.ptr()); +#endif + + mark_vertex(v); + + + while ( k > 0 ) + { +#if defined(USE_LEDA_CONTAINERS) + pq_item it = PQ.find_min(); + Vertex* w = PQ.inf(it); + PQ.del_item(it); +#else + // find minimum from PQ ... + Vertex* w = PQ.top(); PQ.pop(); + priority_number.erase(w); // and clean entry in priority map +#endif + + res.push_back(w->handle()); k--; + + // get the incident vertices of w ... + Vertex_circulator vc = incident_vertices(w->handle()); + Vertex_circulator start =vc; + Vertex* act; + + do { + act = &(*vc); + + if ( (!is_marked(act)) && (! is_infinite(act->handle())) ) + { +#if defined(USE_LEDA_CONTAINERS) + PQ.insert(tr_sqrdist(p,act->point()), act); +#else + priority_number[act] = tr_sqrdist(p,act->point()); + PQ.push(act); +#endif + mark_vertex(act->handle()); + } + + vc++; + } while (vc != start); + + } + } + + + // dfs + // for marking nodes in search procedures + int cur_mark; + +#if defined(USE_LEDA_CONTAINERS) + leda_map mark; +#else + std::map > mark; + + typedef typename std::map >::iterator map_iterator; +#endif + + void init_vertex_marks() + { + cur_mark = 0; +#if defined(USE_LEDA_CONTAINERS) + mark.clear(); +#else + mark.erase(mark.begin(), mark.end()); +#endif + } + + void init_dfs() + { + cur_mark++; + if (cur_mark == MAXINT) init_vertex_marks(); + } + + void mark_vertex(Vertex_handle vh) + // mark vh as visited ... + { + Vertex* v = vh.ptr(); + mark[v] = cur_mark; + } + + bool is_marked(Vertex_handle vh) + { + Vertex* v = vh.ptr(); + +#if defined(USE_LEDA_CONTAINERS) + if (! mark.defined(v)) return false; +#else + map_iterator mit = mark.find(v); + if (mit == mark.end()) return false; +#endif + + return (mark[v] == cur_mark); + } + + void dfs(Vertex_handle v,const Circle& C, std::list& L) + { + L.push_back(v); + mark_vertex(v); + + // get incident vertices of v ... + Vertex_circulator vc = incident_vertices(v); + Vertex_circulator start =vc; + + Vertex_handle act; + + // go through the vertices ... + do { + act = vc->handle(); + + if (! is_infinite(act)) { + if (!is_marked(act) && ! (tr_circleptori(C,act->point())==ON_UNBOUNDED_SIDE) ) + dfs(act,C,L); + } + vc++; + } while (vc != start); + } + + + template + OutputIterator range_search(const Circle& C, OutputIterator res) + { + if (number_of_vertices() == 0) return res; + if (number_of_vertices() == 1) + { + // get the one vertex ... + Vertex_iterator vit = finite_vertices_begin(); + Vertex v = (*vit); + Point p = v.point(); + + if (! (tr_circleptori(C, p) == ON_UNBOUNDED_SIDE)){ + *res= v.handle(); res++; + } + return res; + } + + // normal case ... + Point p = tr_circlecenter(C); + Vertex_handle v = lookup(p); + bool new_v = false; + + if ( v == NULL ) + { + new_v = true; + v = insert(p); + } + + init_dfs(); + + std::list L; + dfs(v,C,L); + + if (new_v) + { L.pop_front(); //first one was inserted in range_search ... + remove(v); + } + + std::list::const_iterator iter = L.begin(); + for(;iter != L.end() ;iter++){ *res= *iter; res++; } + return res; + } + + + template + OutputIterator range_search(const Point& a, const Point& b, const Point& c,OutputIterator res) + { int orient = (int)(tr_orientation(a,b,c)); + Circle C = tr_createcircle_3p(a,b,c); + std::list L; + range_search(C,std::back_inserter(L)); + + std::list::const_iterator it = L.begin(); + + for(;it != L.end();it++) + { Point p = (*it)->point(); + if ( ((int)(tr_orientation(a,b,p))) == - orient || + ((int)(tr_orientation(b,c,p))) == - orient || + ((int)(tr_orientation(c,a,p))) == - orient ) { } + else { *res = *it; res++; } + } + return res; + } + + + template + OutputIterator range_search(const Point& a1, const Point& b1, const Point& c1,const Point& + d1,OutputIterator res) + // a1 lower left, b1 lower right , c1 upper right + { + //Point b(c.xcoord(),a.ycoord()); + //Point d(a.xcoord(),c.ycoord()); + Point a=a1,b=b1,c=c1,d=d1; + + if (tr_orientation(a,b,c) == RIGHTTURN) + { Point tmp = b; + b = d; + d = tmp; + } + + Circle C = tr_createcircle_3p(a,b,c); + + std::list L; + range_search(C,std::back_inserter(L)); + std::list::const_iterator it = L.begin(); + + for(;it != L.end();it++) + { Point p = (*it)->point(); + if ( tr_orientation(a,b,p) == RIGHTTURN || tr_orientation(b,c,p) == RIGHTTURN || + tr_orientation(c,d,p) == RIGHTTURN || tr_orientation(d,a,p) == RIGHTTURN ) { } + else { *res = *it; res++; } + } + return res; + } + + // minimum spanning tree removed ... + //template + //OutputIterator minimum_spanning_tree(OutputIterator result) const + + + + bool IS_NON_DIAGRAM_DART(Edge e) const + { + Face_handle f1 = e.first; + Face_handle f2 = f1->neighbor(e.second); + int i = e.second; + + // flip test + Point a = f1->vertex(cw(i))->point(); + Point b = f1->vertex(i)->point(); + Point c = f1->vertex(ccw(i))->point(); + Point d = f1->mirror_vertex(i)->point(); + + if ((tr_orientation(a,b,c)==LEFTTURN) && (tr_orientation(b,c,d)==LEFTTURN) && + (tr_orientation(c,d,a)==LEFTTURN) && (tr_orientation(d,a,c)==LEFTTURN) && + (tr_so_circle(a,b,c,d)==ON_ORIENTED_BOUNDARY) ) + return true; + return false; + } + + bool is_non_diagram_edge(Edge e) const + { + return IS_NON_DIAGRAM_DART(e); + } + + Edge get_cur_dart() const { return cur_dart; } + void set_cur_dart(Edge e) { cur_dart = e; } + void set_hull_dart(Edge e) { hull_dart = e; } + + Point pos(Vertex_handle v) const + { return v->point(); } + + Point pos_source(Edge e) const + { return segment(e).source(); } + + Point pos_target(Edge e) const + { return segment(e).target(); } + + Segment seg(Edge e) const + { return segment(e); } + +}; + + +CGAL_END_NAMESPACE + + +#endif + diff --git a/Old_Packages/Point_set_2_tb/include/CGAL/Triangulation_euclidean_leda_traits_2.h b/Old_Packages/Point_set_2_tb/include/CGAL/Triangulation_euclidean_leda_traits_2.h new file mode 100644 index 00000000000..a69463c04f7 --- /dev/null +++ b/Old_Packages/Point_set_2_tb/include/CGAL/Triangulation_euclidean_leda_traits_2.h @@ -0,0 +1,555 @@ +// ====================================================================== +// +// Copyright (c) 1999 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------- +// +// release : +// release_date : 2000, December 15 +// +// file : include/CGAL/Triangulation_euclidean_leda_traits_2.h +// package : Point_set_2_tb (0.1) +// maintainer : Matthias Baesken +// revision : 0.1 +// revision_date : 15 December 2000 +// author(s) : Matthias Baesken +// +// coordinator : Matthias Baesken, Trier () +// ====================================================================== + +// LEDA traits classes for CGAL Delaunay triangulation + +#ifndef CGAL_TRIANGULATION_EUCLIDEAN_LEDA_TRAITS_2_H +#define CGAL_TRIANGULATION_EUCLIDEAN_LEDA_TRAITS_2_H + +// float kernel +#include +#include +#include +#include +#include +#include +#include + +// rat kernel +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include + + +//#define LEDA_TRIANG_DEBUG + + +template +class leda_distance { +public: + typedef leda_point Point; + + leda_distance(const I* = NULL) {} + + leda_distance(const Point& p0,const I* = NULL) + { p[0]=p0; } + + leda_distance(const Point& p0, const Point& p1,const I* = NULL) + { p[0]=p0; p[1]=p1; } + + + leda_distance(const Point& p0, const Point& p1, const Point& p2,const I* = NULL) + { p[0]=p0; p[1]=p1; p[2]=p2; } + + void set_point(int i, const Point& q) + { + CGAL_precondition( ((unsigned int) i) < 3 ); + p[i] = q; + } + + Point get_point(int i) const + { + CGAL_precondition( ((unsigned int) i) < 3 ); + return p[i]; + } + + CGAL::Comparison_result compare() const + { + return (CGAL::Comparison_result) (::cmp_distances(p[0], p[1], p[0], p[2])); + } + +private: + Point p[3]; +}; + +template +class leda_rat_distance { +public: + typedef leda_rat_point Point; + + leda_rat_distance(const I* = NULL) {} + + leda_rat_distance(const Point& p0,const I* = NULL) + { p[0]=p0; } + + leda_rat_distance(const Point& p0, const Point& p1,const I* = NULL) + { p[0]=p0; p[1]=p1; } + + leda_rat_distance(const Point& p0, const Point& p1, const Point& p2,const I* = NULL) + { p[0]=p0; p[1]=p1; p[2]=p2; } + + void set_point(int i, const Point& q) + { + CGAL_precondition( ((unsigned int) i) < 3 ); + p[i] = q; + } + + Point get_point(int i) const + { + CGAL_precondition( ((unsigned int) i) < 3 ); + return p[i]; + } + + CGAL::Comparison_result compare() const + { + return (CGAL::Comparison_result) (::cmp_distances(p[0], p[1], p[0], p[2])); + } +private: + Point p[3]; +}; + + +CGAL_BEGIN_NAMESPACE + +// rational kernel ... + +class Leda_rat_compare_x_2 { +public: + Comparison_result operator()(const leda_rat_point &p, const leda_rat_point &q) const + { + return (CGAL::Comparison_result)(leda_rat_point::cmp_x(p, q)); + } +}; + +class Leda_rat_compare_y_2 { +public: + Comparison_result operator()(const leda_rat_point &p, const leda_rat_point &q) const + { + return (CGAL::Comparison_result)(leda_rat_point::cmp_y(p, q)); + } +}; + +class Leda_rat_orientation_2 { +public: + Orientation operator()(const leda_rat_point &p,const leda_rat_point &q, const leda_rat_point &r) const + { + return (CGAL::Orientation)(::orientation(p, q, r)); + } +}; + +class Leda_rat_side_of_oriented_circle_2 { +public: + Oriented_side operator()(const leda_rat_point &p,const leda_rat_point &q, + const leda_rat_point &r, + const leda_rat_point &s) const + { + return (CGAL::Oriented_side)(::side_of_circle(p, q, r, s)); + } +}; + +class Leda_rat_construct_circumcenter_2 { +public: + leda_rat_point operator()(const leda_rat_point &p, const leda_rat_point &q, const leda_rat_point &r) const + { + leda_rat_circle C(p,q,r); + return C.center(); + } +}; + +class Leda_rat_construct_bisector_2 { +public: + leda_rat_line operator()(const leda_rat_point &p1, leda_rat_point& p2) const + { + return leda_rat_line(::p_bisector(p1,p2)); + } +}; + +class Leda_rat_construct_midpoint { +public: + leda_rat_point operator()(const leda_rat_point &p, const leda_rat_point &q) const + { + return ::midpoint(p,q); + } +}; + +class Leda_rat_construct_segment_2 { +public: + leda_rat_segment operator()(const leda_rat_point &p, const leda_rat_point &q) const + { + return leda_rat_segment(p,q); + } +}; + +class Leda_rat_construct_triangle_2 { +public: + leda_rat_triangle operator()(const leda_rat_point &p, const leda_rat_point &q, const leda_rat_point &r) const + { + return leda_rat_triangle(p,q,r); + } +}; + +class Leda_rat_less_distance_to_point_2 { + leda_rat_point _p; +public: + Leda_rat_less_distance_to_point_2( const leda_rat_point& p) : _p(p) {} + + bool operator()( const leda_rat_point& p1, const leda_rat_point& p2) const + { + int c = ::cmp_distances(_p,p1,_p,p2); + if (c==-1) return true; else return false; + } +}; + +class Leda_rat_construct_direction_of_line_2 { +public: + leda_rat_vector operator()( const leda_rat_line& l) + { return (l.point2() - l.point1()); } +}; + +class Leda_rat_construct_ray_2 { +public: + leda_rat_ray operator()(const leda_rat_point& p, const leda_rat_vector& d) + { return leda_rat_ray(p, p+d); } +}; + + +// float kernel ... + +class Leda_float_compare_x_2 { +public: + Comparison_result operator()(const leda_point &p, const leda_point &q) const + { +#if defined LEDA_TRIANG_DEBUG + std::cout << "compare_x_2!\n"; std::cout.flush(); +#endif + return (CGAL::Comparison_result)(leda_point::cmp_x(p, q)); + } +}; + +class Leda_float_compare_y_2 { +public: + Comparison_result operator()(const leda_point &p, const leda_point &q) const + { +#if defined LEDA_TRIANG_DEBUG + std::cout << "compare_y_2!\n"; std::cout.flush(); +#endif + return (CGAL::Comparison_result)(leda_point::cmp_y(p, q)); + } +}; + +class Leda_float_orientation_2 { +public: + Orientation operator()(const leda_point &p,const leda_point &q, const leda_point &r) const + { +#if defined LEDA_TRIANG_DEBUG + std::cout << "orientation_2!\n"; std::cout.flush(); +#endif + return (CGAL::Orientation)(::orientation(p, q, r)); + } +}; + +class Leda_float_side_of_oriented_circle_2 { +public: + Oriented_side operator()(const leda_point &p,const leda_point &q, + const leda_point &r, + const leda_point &s) const + { +#if defined LEDA_TRIANG_DEBUG + std::cout << "side_of_oriented_circle_2!\n"; std::cout.flush(); + if (::collinear(p, q, r)) { std::cout << " circle is degenerate!\n"; std::cout.flush(); } +#endif + return (CGAL::Oriented_side)(::side_of_circle(p, q, r, s)); + } +}; + +class Leda_float_construct_circumcenter_2 { +public: + leda_point operator()(const leda_point &p, const leda_point &q, const leda_point &r) const + { +#if defined LEDA_TRIANG_DEBUG + std::cout << "construct_circumcenter_2!\n"; std::cout.flush(); +#endif + if (::collinear(p,q,r)){ + std::cout << "collinear!\n"; std::cout.flush(); + return leda_point(); + } + else { + leda_circle C(p,q,r); + return C.center(); + } + } +}; + +class Leda_float_construct_bisector_2 { +public: + leda_line operator()(const leda_point& p1, const leda_point& p2 ) const + { +#if defined LEDA_TRIANG_DEBUG + std::cout << "construct_bisector_2!\n"; std::cout.flush(); +#endif + return leda_line(::p_bisector(p1,p2)); + } +}; + +class Leda_float_construct_midpoint { +public: + leda_point operator()(const leda_point &p, const leda_point &q) const + { +#if defined LEDA_TRIANG_DEBUG + std::cout << "construct_midpoint!\n"; std::cout.flush(); +#endif + return ::midpoint(p,q); + } +}; + +class Leda_float_construct_segment_2 { +public: + leda_segment operator()(const leda_point &p, const leda_point &q) const + { +#if defined LEDA_TRIANG_DEBUG + std::cout << "construct_segment_2!\n"; std::cout.flush(); +#endif + return leda_segment(p,q); + } +}; + +class Leda_float_construct_triangle_2 { +public: + leda_triangle operator()(const leda_point &p, const leda_point &q, const leda_point &r) const + { +#if defined LEDA_TRIANG_DEBUG + std::cout << "construct_triangle_2!\n"; std::cout.flush(); +#endif + return leda_triangle(p,q,r); + } +}; + +class Leda_float_less_distance_to_point_2 { + leda_point _p; +public: + Leda_float_less_distance_to_point_2( const leda_point& p) : _p(p) {} + + bool operator()( const leda_point& p1, const leda_point& p2) const + { +#if defined LEDA_TRIANG_DEBUG + std::cout << "less_distance_to_point_2!\n"; std::cout.flush(); +#endif + int c = ::cmp_distances(_p,p1,_p,p2); + if (c==-1) return true; else return false; + } +}; + +class Leda_float_construct_direction_of_line_2 { +public: + leda_vector operator()( const leda_line& l) + { +#if defined LEDA_TRIANG_DEBUG + std::cout << "construct_direction_of_line_2!\n"; std::cout.flush(); +#endif + return (l.point2() - l.point1()); + } +}; + +class Leda_float_construct_ray_2 { +public: + leda_ray operator()(const leda_point& p, const leda_vector& d) + { +#if defined LEDA_TRIANG_DEBUG + std::cout << "construct_ray_2!\n"; std::cout.flush(); +#endif + return leda_ray(p,d); + } +}; + + +class Triangulation_euclidean_leda_rat_traits_2 { +public: + typedef leda_rational Rep; + typedef leda_rat_point Point_2; + typedef leda_rat_segment Segment_2; + typedef leda_rat_triangle Triangle_2; + typedef leda_rat_circle Circle_2; + typedef leda_rat_line Line_2; + typedef leda_rat_ray Ray_2; + typedef leda_rat_vector Direction_2; + typedef leda_rat_distance Distance; + + // new + typedef Leda_rat_compare_x_2 Compare_x_2; + typedef Leda_rat_compare_y_2 Compare_y_2; + typedef Leda_rat_orientation_2 Orientation_2; + typedef Leda_rat_side_of_oriented_circle_2 Side_of_oriented_circle_2; + typedef Leda_rat_construct_circumcenter_2 Construct_circumcenter_2; + typedef Leda_rat_construct_bisector_2 Construct_bisector_2; + typedef Leda_rat_construct_segment_2 Construct_segment_2; + typedef Leda_rat_construct_triangle_2 Construct_triangle_2; + typedef Leda_rat_construct_midpoint Construct_midpoint; + typedef Leda_rat_less_distance_to_point_2 Less_distance_to_point_2; + + typedef Leda_rat_construct_direction_of_line_2 Construct_direction_of_line_2; + typedef Leda_rat_construct_ray_2 Construct_ray_2; + + + Triangulation_euclidean_leda_rat_traits_2() {} + Triangulation_euclidean_leda_rat_traits_2(const Triangulation_euclidean_leda_rat_traits_2 &) {} + Triangulation_euclidean_leda_rat_traits_2 &operator= + (const Triangulation_euclidean_leda_rat_traits_2 &) + {return *this;} + + Compare_x_2 + compare_x_2_object() const + { return Compare_x_2();} + + Compare_y_2 + compare_y_2_object() const + { return Compare_y_2();} + + Orientation_2 + orientation_2_object() const + { return Orientation_2();} + + Side_of_oriented_circle_2 + side_of_oriented_circle_2_object() const + {return Side_of_oriented_circle_2();} + + Construct_circumcenter_2 + construct_circumcenter_2_object() const + { return Construct_circumcenter_2();} + + Construct_bisector_2 + construct_bisector_2_object() const + {return Construct_bisector_2();} + + Construct_midpoint + construct_midpoint_object() const + {return Construct_midpoint();} + + Construct_segment_2 + construct_segment_2_object() const + {return Construct_segment_2(); } + + Construct_triangle_2 + construct_triangle_2_object() const + {return Construct_triangle_2(); } + + Less_distance_to_point_2 + less_distance_to_point_2_object(const Point_2& p) const + {return Less_distance_to_point_2(p);} + + Construct_direction_of_line_2 + construct_direction_of_line_2_object() const + { return Construct_direction_of_line_2(); } + + Construct_ray_2 + construct_ray_2_object() const + { return Construct_ray_2(); } +}; + + +class Triangulation_euclidean_leda_float_traits_2 { +public: + typedef double Rep; + typedef leda_point Point_2; + typedef leda_segment Segment_2; + typedef leda_triangle Triangle_2; + typedef leda_circle Circle_2; + typedef leda_line Line_2; + typedef leda_ray Ray_2; + typedef leda_vector Direction_2; + typedef leda_distance Distance; + + // new + typedef Leda_float_compare_x_2 Compare_x_2; + typedef Leda_float_compare_y_2 Compare_y_2; + typedef Leda_float_orientation_2 Orientation_2; + typedef Leda_float_side_of_oriented_circle_2 Side_of_oriented_circle_2; + typedef Leda_float_construct_circumcenter_2 Construct_circumcenter_2; + typedef Leda_float_construct_bisector_2 Construct_bisector_2; + typedef Leda_float_construct_segment_2 Construct_segment_2; + typedef Leda_float_construct_triangle_2 Construct_triangle_2; + typedef Leda_float_construct_midpoint Construct_midpoint; + typedef Leda_float_less_distance_to_point_2 Less_distance_to_point_2; + + typedef Leda_float_construct_direction_of_line_2 Construct_direction_of_line_2; + typedef Leda_float_construct_ray_2 Construct_ray_2; + + + Triangulation_euclidean_leda_float_traits_2() {} + Triangulation_euclidean_leda_float_traits_2(const Triangulation_euclidean_leda_float_traits_2 &) {} + Triangulation_euclidean_leda_float_traits_2 &operator= + (const Triangulation_euclidean_leda_float_traits_2 &) + {return *this;} + + Compare_x_2 + compare_x_2_object() const + { return Compare_x_2();} + + Compare_y_2 + compare_y_2_object() const + { return Compare_y_2();} + + Orientation_2 + orientation_2_object() const + { return Orientation_2();} + + Side_of_oriented_circle_2 + side_of_oriented_circle_2_object() const + {return Side_of_oriented_circle_2();} + + Construct_circumcenter_2 + construct_circumcenter_2_object() const + { return Construct_circumcenter_2();} + + Construct_bisector_2 + construct_bisector_2_object() const + {return Construct_bisector_2();} + + Construct_midpoint + construct_midpoint_object() const + {return Construct_midpoint();} + + Construct_segment_2 + construct_segment_2_object() const + {return Construct_segment_2(); } + + Construct_triangle_2 + construct_triangle_2_object() const + {return Construct_triangle_2(); } + + Less_distance_to_point_2 + less_distance_to_point_2_object(const Point_2& p) const + {return Less_distance_to_point_2(p);} + + Construct_direction_of_line_2 + construct_direction_of_line_2_object() const + { return Construct_direction_of_line_2(); } + + Construct_ray_2 + construct_ray_2_object() const + { return Construct_ray_2(); } +}; + + +CGAL_END_NAMESPACE + +#endif // CGAL_TRIANGULATION_EUCLIDEAN_TRAITS_2_H diff --git a/Old_Packages/Point_set_2_tb/maintainer b/Old_Packages/Point_set_2_tb/maintainer new file mode 100644 index 00000000000..5ceaaa5d811 --- /dev/null +++ b/Old_Packages/Point_set_2_tb/maintainer @@ -0,0 +1 @@ +Matthias Baesken diff --git a/Old_Packages/Point_set_2_tb/version b/Old_Packages/Point_set_2_tb/version new file mode 100644 index 00000000000..a7ef6a41ed4 --- /dev/null +++ b/Old_Packages/Point_set_2_tb/version @@ -0,0 +1,2 @@ +0.1 (15 December 2000) +maintainer: Matthias Baesken diff --git a/Packages/Point_set_2/changes.txt b/Packages/Point_set_2/changes.txt new file mode 100644 index 00000000000..ab77984b70d --- /dev/null +++ b/Packages/Point_set_2/changes.txt @@ -0,0 +1,62 @@ +1.2.4 - HTML Manual changes + +1.2.3 - added some \ccHtmlNoLinksFrom in the documentation to prevent linking of Vertex/Line + in the HTML Manual version + +1.2.2 - some manual changes + +1.2.1 - small changes to Point_set_2.h to please MSVC + - LEDA check added to program files + +1.2 - manual split (into user - and reference manual) + - Point_set_2.h reorganized + +1.1.8 - no more usage of LEDA/rat_window.h + (is not available on LEDA 3.7.1) + +1.1.6 - demo makefile changed + - a typename added for g++ in Point_set_2.h to please g++ -pedantic + +1.1.5 - changed demo makefile + - renaming of traits in manual + - additions in testsuite + +1.1.4 - 2x std::std removed from Point_set_2.h + +1.1.3 - demos changed (no using any more, some other small changes) + - cerr -> std::cerr in Point_set_2.h + +1.1.2 - test and examples makefile changed for BC + +1.1.1 - function save_state and inclusion of fstream-headers + removed + +1.1 - Pointset_2 -> Point_set_2 + - Traits classes changed + - lots of changes in the manual + +1.0.9 - makefiles changed + +1.0.8 - removed some endl without the std:: prefix + +1.0.7 - GeoWin demos changed + - some demo - Makefiles changed + - lookup crash on empty pointset fixed + +1.0.6 - demos changed; some typename stuff in + pointset_cgaltraits_2.h changed for MSVC + +1.0.5 - changes in Pointset_2.h for compatibility with older LEDA versions + +1.0.4 - small change in Pointset_2.h + +1.0.3 - some demos were changed + +1.0.2 - changes in Makefiles + - added inclusion of CGAL/config.h at the beginning of programs + - small change for better VC - compatibility + +1.0.1 - some demo programs changed + - 2 errors in the file headers fixed + +1.0 First released version of the Pointset_2 for CGAL diff --git a/Packages/Point_set_2/demo/Point_set_2/GeoWin/Makefile b/Packages/Point_set_2/demo/Point_set_2/GeoWin/Makefile new file mode 100644 index 00000000000..62605110fcf --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/GeoWin/Makefile @@ -0,0 +1,38 @@ +include $(CGAL_MAKEFILE) + +CC = $(CGAL_CXX) $(CGAL_WINDOW_LIBPATH) + +CGALCFLAGS = $(CGAL_CXXFLAGS) + + +CGDL = $(CGAL_GEOWIN_LDFLAGS) + +geowin_pset_2d$(EXE_EXT) : geowin_pset_2d$(OBJ_EXT) + $(CC) $(EXE_OPT)geowin_pset_2d geowin_pset_2d$(OBJ_EXT) $(CGDL) + +geowin_k_nearest_neighbors$(EXE_EXT) : geowin_k_nearest_neighbors$(OBJ_EXT) + $(CC) $(EXE_OPT)geowin_k_nearest_neighbors geowin_k_nearest_neighbors$(OBJ_EXT) $(CGDL) + + +clean : + rm -f tt *~ *.o *.obj *.exe + rm -f geowin_k_nearest_neighbors geowin_pset_2d + + +all: geowin_k_nearest_neighbors geowin_pset_2d + + +cleano : + rm -f *~ *.o + + +#---------------------------------------------------------------------# +# suffix rules +#---------------------------------------------------------------------# + +.C$(OBJ_EXT): + $(CGAL_CXX) $(CGALCFLAGS) -c $< + +.c$(OBJ_EXT): + $(CGAL_CXX) $(CGALCFLAGS) -c $< + diff --git a/Packages/Point_set_2/demo/Point_set_2/GeoWin/geowin_k_nearest_neighbors.C b/Packages/Point_set_2/demo/Point_set_2/GeoWin/geowin_k_nearest_neighbors.C new file mode 100644 index 00000000000..ca955c4a91c --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/GeoWin/geowin_k_nearest_neighbors.C @@ -0,0 +1,111 @@ +#include + +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 400) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA 4.0 or higher installed!\n"; + std::cout << "A LEDA version >= 4.0 is required !\n"; + return 0; +} +#else + + +#include +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +CGAL::Point_set_2 PST; +int k; + +class construct_pointset : public geowin_update >,std::list > > +{ +public: + void update(const std::list >& Lin, std::list >& Lout) + { + PST.init(Lin.begin(),Lin.end()); + Lout.clear(); + PST.segments(std::back_inserter(Lout)); + } +}; + +class mst : public geowin_update >, std::list > > +{ +public: + void update(const std::list >& Lin, std::list >& Lout) + { + Lout.clear(); + std::list output; + std::list::const_iterator pit; + + PST.minimum_spanning_tree( std::back_inserter(output)); + + for (pit=output.begin(); pit != output.end(); pit++){ + Lout.push_back(CGALSegment(PST.seg(*pit))); + } + } +}; + +class nearest_neighbors : public geowin_update >, std::list > > +{ +public: + void update(const std::list >& Lin, std::list >& Lout) + { + Lout.clear(); + std::list >::const_iterator it = Lin.begin(); + std::list output; + std::list::const_iterator pit; + + for (; it != Lin.end(); it++){ + PST.nearest_neighbors(*it, k, std::back_inserter(output)); + } + for (pit=output.begin(); pit != output.end(); pit++){ + Lout.push_back(CGALCircle(PST.pos(*pit),2.0)); + } + } +}; + +int main() +{ + geowin_init_default_type((std::list >*)0, leda_string("CGALPointlist")); + + std::cout << "Find the k nearest neighbors of every point in scene 2.\n"; + std::cout << "k:"; std::cin >> k; + + GeoWin gw; + + std::list > Lp; + geo_scene sc1 = gw.new_scene(Lp); + + std::list > Lother; + geo_scene sc2 = gw.new_scene(Lother); + gw.set_color(sc2,leda_blue); + + construct_pointset CP; + geo_scene sc3 = gw.new_scene(CP, sc1, leda_string("2d point set")); + gw.set_color(sc3,leda_blue); + + nearest_neighbors NN; + geo_scene sc4 = gw.new_scene(NN, sc2, leda_string("k nearest neighbors")); + gw.set_fill_color(sc4,leda_red); + gw.set_color(sc4,leda_red); + gw.set_point_style(sc4,leda_circle_point); + gw.set_line_width(sc4,4); + + mst MS; + geo_scene sc5 = gw.new_scene(MS, sc1, leda_string("Minimum spanning tree")); + gw.set_line_width(sc5,2); + + gw.set_all_visible(true); + gw.add_dependence(sc1,sc4); + + gw.edit(sc1); + + return 0; +} +#endif diff --git a/Packages/Point_set_2/demo/Point_set_2/GeoWin/geowin_pset_2d.C b/Packages/Point_set_2/demo/Point_set_2/GeoWin/geowin_pset_2d.C new file mode 100644 index 00000000000..ae227bbbe39 --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/GeoWin/geowin_pset_2d.C @@ -0,0 +1,120 @@ +#include + +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 400) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA 4.0 or higher installed!\n"; + std::cout << "A LEDA version >= 4.0 is required !\n"; + return 0; +} +#else + + +#include +#include + + +typedef CGAL::Cartesian REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +CGAL::Point_set_2 PST; + +class construct_pointset : public geowin_update, std::list > +{ +public: + void update(const std::list& Lin, std::list& Lout) + { + PST.init(Lin.begin(),Lin.end()); + Lout.clear(); + PST.segments(std::back_inserter(Lout)); + } +}; + +class circle_range_search : public geowin_update, std::list > +{ + void update(const std::list& Lin, std::list& Lout) + { + Lout.clear(); + std::list::const_iterator it = Lin.begin(); + std::list output; + std::list::const_iterator pit; + + for (; it != Lin.end(); it++){ + PST.range_search(*it, std::back_inserter(output)); + } + for (pit=output.begin(); pit != output.end(); pit++){ + Lout.push_back(CGALCircle(PST.pos(*pit),2.0)); + } + } +}; + +class triangle_range_search : public geowin_update, std::list > +{ +public: + void update(const std::list& Lin, std::list& Lout) + { + Lout.clear(); + std::list::const_iterator it = Lin.begin(); + std::list output; + std::list::const_iterator pit; + + for (; it != Lin.end(); it++){ + PST.range_search((*it).vertex(0),(*it).vertex(1),(*it).vertex(2), std::back_inserter(output)); + } + for (pit=output.begin(); pit != output.end(); pit++){ + Lout.push_back(CGALCircle(PST.pos(*pit),1.0)); + } + } +}; + +int main() +{ + geowin_init_default_type((CGALPointlist*)0, leda_string("CGALPointlist")); + geowin_init_default_type((CGALCirclelist*)0, leda_string("CGALCirclelist")); + geowin_init_default_type((CGALTrianglelist*)0, leda_string("CGALTrianglelist")); + + GeoWin gw; + + std::list Lp; + geo_scene sc1 = gw.new_scene(Lp); + + std::list Lc; + geo_scene sc_circ = gw.new_scene(Lc); + gw.set_color(sc_circ, leda_blue); + gw.set_fill_color(sc_circ, leda_invisible); + + std::list Lt; + geo_scene sc_triang = gw.new_scene(Lt); + gw.set_color(sc_triang, leda_blue2); + gw.set_line_width(sc_triang,3); + gw.set_active_line_width(sc_triang,3); + gw.set_fill_color(sc_triang, leda_invisible); + + construct_pointset CP; + gw.new_scene(CP, sc1, leda_string("2d point set")); + + circle_range_search CRS; + geo_scene sc3 = gw.new_scene(CRS, sc_circ, leda_string("circular range search")); + gw.set_color(sc3,leda_red); + gw.set_point_style(sc3, leda_circle_point); + gw.set_line_width(sc3,4); + + triangle_range_search TRS; + geo_scene sc4 = gw.new_scene(TRS, sc_triang, leda_string("triangular range search")); + gw.set_color(sc4,leda_green); + gw.set_point_style(sc4, leda_circle_point); + gw.set_line_width(sc4,4); + + gw.set_all_visible(true); + gw.add_dependence(sc1,sc3); + gw.add_dependence(sc1,sc4); + + gw.edit(sc1); + + return 0; +} +#endif diff --git a/Packages/Point_set_2/demo/Point_set_2/Makefile b/Packages/Point_set_2/demo/Point_set_2/Makefile new file mode 100644 index 00000000000..1610012711c --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/Makefile @@ -0,0 +1,53 @@ +include $(CGAL_MAKEFILE) + +CC = $(CGAL_CXX) $(CGAL_WINDOW_LIBPATH) + +CGALCFLAGS = $(CGAL_CXXFLAGS) + +CGDL = $(CGAL_WINDOW_LDFLAGS) + +ps_test1$(EXE_EXT) : ps_test1$(OBJ_EXT) + $(CC) $(EXE_OPT)ps_test1 ps_test1$(OBJ_EXT) $(CGDL) + +voronoi$(EXE_EXT) : voronoi$(OBJ_EXT) + $(CC) $(EXE_OPT)voronoi voronoi$(OBJ_EXT) $(CGDL) + +rtest$(EXE_EXT) : rtest$(OBJ_EXT) + $(CC) $(EXE_OPT)rtest rtest$(OBJ_EXT) $(CGDL) + +ps_test1_cgal$(EXE_EXT) : ps_test1_cgal$(OBJ_EXT) + $(CC) $(EXE_OPT)ps_test1_cgal ps_test1_cgal$(OBJ_EXT) $(CGDL) + +nearest_neighbor$(EXE_EXT) : nearest_neighbor$(OBJ_EXT) + $(CC) $(EXE_OPT)nearest_neighbor nearest_neighbor$(OBJ_EXT) $(CGDL) + +locate_test$(EXE_EXT) : locate_test$(OBJ_EXT) + $(CC) $(EXE_OPT)locate_test locate_test$(OBJ_EXT) $(CGDL) + +range_search$(EXE_EXT) : range_search$(OBJ_EXT) + $(CC) $(EXE_OPT)range_search range_search$(OBJ_EXT) $(CGDL) + +range_search_hm$(EXE_EXT) : range_search_hm$(OBJ_EXT) + $(CC) $(EXE_OPT)range_search_hm range_search_hm$(OBJ_EXT) $(CGDL) + +locate_test_hm$(EXE_EXT) : locate_test_hm$(OBJ_EXT) + $(CC) $(EXE_OPT)locate_test_hm locate_test_hm$(OBJ_EXT) $(CGDL) + +clean : + rm -f tt *~ *.o *.obj *.exe core + rm -f voronoi ps_test1 ps_test1_cgal nearest_neighbor locate_test range_search range_search_hm locate_test_hm + +all: ps_test1_cgal nearest_neighbor locate_test range_search range_search_hm locate_test_hm + +cleano : + rm -f *~ *.o + + +#---------------------------------------------------------------------# +# suffix rules +#---------------------------------------------------------------------# + +.C$(OBJ_EXT): + $(CGAL_CXX) $(CGALCFLAGS) $(OBJ_OPT) $< + + diff --git a/Packages/Point_set_2/demo/Point_set_2/README b/Packages/Point_set_2/demo/Point_set_2/README new file mode 100644 index 00000000000..757be5f3044 --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/README @@ -0,0 +1,14 @@ +Various demonstration programs for the 2d Pointset. +All use the LEDA window class for visualization. + +GeoWin: +In this folder are 2 demos using the GeoWin library. + +geowin_pset_2d: range searches on the Pointset_2 +geowin_k_nearest_neighbors: nearest neighbors, minimum spanning tree + + + + +- note that for optimising compilation you have to add on some platforms +the flag -fno_default_inline diff --git a/Packages/Point_set_2/demo/Point_set_2/locate_test.C b/Packages/Point_set_2/demo/Point_set_2/locate_test.C new file mode 100644 index 00000000000..cc88e85b267 --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/locate_test.C @@ -0,0 +1,80 @@ +#include + +#if !defined(CGAL_USE_LEDA) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + +#include +#include +#include +#include +#include +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +leda_segment get_seg(const CGAL::Segment_2& s) +{ + CGAL::Point_2 ps=s.source(); + CGAL::Point_2 pt=s.target(); + + leda_rat_point p1(ps.x(),ps.y()), p2(pt.x(),pt.y()); + + return leda_segment(p1.to_point(),p2.to_point()); +} + +void output(leda_window& W, const CGAL::Point_set_2& PSet) +{ + W.clear(); + leda_edge e; + forall_edges(e,PSet) { + CGAL::Segment_2 s= PSet.seg(e); + W << get_seg(s); + } +} + +int main() +{ + int i; + CGAL::Point_set_2 PSet; + CGAL::Point_2 actual; + + leda_window W(600,500,leda_string("Input vertices of the Delaunay Triangulation!")); + CGAL::cgalize( W); + + W.init(-500,500,-400); + W.display(100,100); + + // read in 20 points ... + for (i=0; i<20; i++){ + W >> actual; + PSet.insert(actual); + output(W,PSet); + } + + W.set_frame_label(leda_string("Locate!")); + // locate ... + for (i=0; i<10; i++){ + W >> actual; + Edge e = PSet.locate(actual); + + CGAL::Segment_2 my_seg = PSet.seg(e); + + W << CGAL::BLUE << my_seg << CGAL::BLACK; + } + + W.read_mouse(); + + return 0; +} + +#endif diff --git a/Packages/Point_set_2/demo/Point_set_2/locate_test_hm.C b/Packages/Point_set_2/demo/Point_set_2/locate_test_hm.C new file mode 100644 index 00000000000..d9ac624baa8 --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/locate_test_hm.C @@ -0,0 +1,80 @@ +#include + +#if !defined(CGAL_USE_LEDA) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + +#include +#include +#include +#include +#include +#include + +typedef CGAL::Homogeneous REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +leda_segment get_seg(const CGAL::Segment_2& s) +{ + CGAL::Point_2 ps=s.source(); + CGAL::Point_2 pt=s.target(); + + leda_rat_point p1(ps.hx()/ps.hw(),ps.hy()/ps.hw()); + leda_rat_point p2(pt.hx()/ps.hw(),pt.hy()/ps.hw()); + + return leda_segment(p1.to_point(),p2.to_point()); +} + +void output(leda_window& W, const CGAL::Point_set_2& PSet) +{ + W.clear(); + leda_edge e; + forall_edges(e,PSet) { + CGAL::Segment_2 s = PSet.seg(e); + W << get_seg(s); + } +} + +int main() +{ + int i; + CGAL::Point_set_2 PSet; + CGAL::Point_2 actual; + + leda_window W(600,500,leda_string("Input vertices of the Delaunay Triangulation!")); + CGAL::cgalize( W); + + W.init(-500,500,-400); + W.display(100,100); + + // read in 20 points ... + for (i=0; i<20; i++){ + W >> actual; + PSet.insert(actual); + output(W,PSet); + } + + // locate ... + for (i=0; i<5; i++){ + W >> actual; + Edge e = PSet.locate(actual); + + CGAL::Segment_2 my_seg = PSet.seg(e); + + W << CGAL::BLUE << my_seg << CGAL::BLACK; + } + + W.read_mouse(); + + return 0; +} + +#endif diff --git a/Packages/Point_set_2/demo/Point_set_2/nearest_neighbor.C b/Packages/Point_set_2/demo/Point_set_2/nearest_neighbor.C new file mode 100644 index 00000000000..8d79cd4b118 --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/nearest_neighbor.C @@ -0,0 +1,100 @@ +#include + +#if !defined(CGAL_USE_LEDA) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + +#include +#include +#include +#include +#include +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +leda_segment get_seg(const CGAL::Segment_2& s) +{ + CGAL::Point_2 ps=s.source(); + CGAL::Point_2 pt=s.target(); + + leda_rat_point p1(ps.x(),ps.y()), p2(pt.x(),pt.y()); + + return leda_segment(p1.to_point(),p2.to_point()); +} + +void output(leda_window& W, const CGAL::Point_set_2& PSet) +{ + W.clear(); + leda_edge e; + forall_edges(e,PSet) { + CGAL::Segment_2 s= PSet.seg(e); + W << get_seg(s); + } +} + +int main() +{ + CGAL::Point_set_2 PSet; + + leda_window W(600,500, leda_string("Finding nearest neighbors")); + CGAL::cgalize( W); + + W.init(-500,500,-400); + W.display(100,100); + + CGAL::Point_2 actual; + int i; + + for (i=0; i<25; i++){ + W >> actual; + PSet.insert(actual); + output(W,PSet); + } + + // nearest neighbor ... + for (i=0; i<5; i++){ + W >> actual; + Vertex v = PSet.nearest_neighbor(actual); + + CGAL::Segment_2 my_seg(actual,PSet.pos(v)); + + W << CGAL::RED << PSet.pos(v) << CGAL::BLACK; + W << CGAL::BLUE << my_seg << CGAL::BLACK; + } + + // k nearest neighbors ... + std::list L; + std::list::const_iterator it; + + for (i=0; i<5; i++){ + L.clear(); + W >> actual; + PSet.nearest_neighbors(actual,5, std::back_inserter(L)); + std::cout << "actual point: " << actual << "\n"; + + W.clear(); + output(W,PSet); + W << CGAL::RED << actual << CGAL::BLACK; + + for (it=L.begin();it != L.end(); it++){ + W << CGAL::GREEN << PSet.pos(*it) << CGAL::BLACK; + std::cout << PSet.pos(*it) << "\n"; + } + std::cout << "\n"; + } + + W.read_mouse(); + + return 0; +} +#endif diff --git a/Packages/Point_set_2/demo/Point_set_2/ps_test1.C b/Packages/Point_set_2/demo/Point_set_2/ps_test1.C new file mode 100644 index 00000000000..d337d84ff24 --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/ps_test1.C @@ -0,0 +1,111 @@ +#include + +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 400) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA 4.0 or higher installed!\n"; + std::cout << "A LEDA version >= 4.0 is required !\n"; + return 0; +} +#else + + +// Pointset demo using LEDA lists as containers; +// LEDA 4.0 or higher should be used + +#include +#include +#include +#include +#include + + +typedef CGAL::point_set_leda_rat_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +void output(leda_window& W, const CGAL::Point_set_2& PSR_rat) +{ + W.clear(); + leda_edge e; + forall_edges(e,PSR_rat) W << leda_segment(PSR_rat.seg(e).to_segment()); +} + +int main() +{ + int i; + CGAL::Point_set_2 PSR_rat; + leda_window W(500,400); + W.init(-500,500,-400); + W.display(); + + for (i=0; i<30; i++) { + leda_rat_point pnew; + W >> pnew; + PSR_rat.insert(pnew); + output(W,PSR_rat); + } + + for (i=0; i<3; i++) { + leda_rat_point pnew; + W >> pnew; + Vertex v = PSR_rat.nearest_neighbor(pnew); + PSR_rat.del(v); + output(W,PSR_rat); + } + + leda_rat_circle rc; + W >> rc; W << rc; + +#if (__LEDA__ >= 400) + W.set_point_style(leda_disc_point); +#endif + + leda_list LV = PSR_rat.range_search(rc); + Vertex v; + W.set_color(leda_red); + forall(v,LV) W << PSR_rat.pos(v); + + std::cout << "circular range_search - found " << LV.size() << " vertices!\n"; + + std::cout << "range search for triangle !\n"; + leda_rat_point pt1,pt2,pt3,pt4; + W >> pt1; W << pt1; + W >> pt2; W << pt2; + W >> pt3; W << pt3; + + LV.clear(); + PSR_rat.range_search(pt1,pt2,pt3,std::back_inserter(LV)); + leda_list::iterator it; + W.set_color(leda_green); + + for (it=LV.begin();it != LV.end(); it++) + W << PSR_rat.pos(*it); + + std::cout << "triangular range_search - found " << LV.size() << " vertices!\n"; + + LV.clear(); + + W >> pt1; W << pt1; + W >> pt3; W << pt3; + + pt2 = leda_rat_point(pt3.xcoord(),pt1.ycoord()); + pt4 = leda_rat_point(pt1.xcoord(),pt3.ycoord()); + + W.set_color(leda_orange); + PSR_rat.range_search(pt1,pt2,pt3,pt4,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + W << PSR_rat.pos(*it); + + std::cout << "rectangular range_search - found " << LV.size() << " vertices!\n"; + + leda_list El = PSR_rat.minimum_spanning_tree(); + + std::cout << "\nMST: " << El.size() << " vertices\n"; + + W.read_mouse(); + return 0; +} +#endif diff --git a/Packages/Point_set_2/demo/Point_set_2/ps_test1_cgal.C b/Packages/Point_set_2/demo/Point_set_2/ps_test1_cgal.C new file mode 100644 index 00000000000..3b209482b41 --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/ps_test1_cgal.C @@ -0,0 +1,131 @@ +#include + +#if !defined(CGAL_USE_LEDA) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + +#include +#include +#include +#include +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +leda_segment get_seg(const CGAL::Segment_2& s) +{ + CGAL::Point_2 ps=s.source(); + CGAL::Point_2 pt=s.target(); + + leda_point p1(ps.x(),ps.y()), p2(pt.x(),pt.y()); + return leda_segment(p1,p2); +} + +void output(leda_window& W, const CGAL::Point_set_2& PSR_rat) +{ + W.clear(); + leda_edge e; + forall_edges(e,PSR_rat) { + CGAL::Segment_2 s= PSR_rat.seg(e); + W << get_seg(s); + } +} + +int main() +{ + int i; + CGAL::Point_set_2 PSR_rat; + + leda_window W(600,500); + CGAL::cgalize( W); + + W.init(-500,500,-400); + W.display(100,100); + + output(W,PSR_rat); + + for (i=0; i<25; i++) { + CGAL::Point_2 pnew; + W >> pnew; + PSR_rat.insert(pnew); + output(W,PSR_rat); + } + + for (i=0; i<2; i++) { + CGAL::Point_2 pnew; + W >> pnew; + Vertex v = PSR_rat.nearest_neighbor(pnew); + PSR_rat.del(v); + output(W,PSR_rat); + } + + std::cout << "circular range search !\n"; + + CGAL::Circle_2 rc; + W >> rc; + + std::list LV; + std::list::const_iterator vit; + + PSR_rat.range_search(rc,std::back_inserter(LV)); + + W.set_color(leda_red); + for(vit=LV.begin(); vit!=LV.end(); vit++){ + W << PSR_rat.pos(*vit); + } + W.set_color(leda_black); + + std::cout << LV.size() << "\n"; + + std::cout << "triangular range search !\n"; + + CGAL::Point_2 pt1,pt2,pt3,pt4; + W >> pt1; + W >> pt2; + W >> pt3; + + std::list outlist; + + PSR_rat.range_search(pt1,pt2,pt3,std::back_inserter(outlist)); + W.set_color(leda_green); + for(vit=outlist.begin(); vit!=outlist.end(); vit++){ + W << PSR_rat.pos(*vit); + } + W.set_color(leda_black); + + std::cout << outlist.size() << "\n"; + + outlist.clear(); + + std::cout << "rectangular range search !\n"; + W >> pt1; W >> pt3; + + pt2 = CGAL::Point_2(pt3.x(),pt1.y()); + pt4 = CGAL::Point_2(pt1.x(),pt3.y()); + + PSR_rat.range_search(pt1,pt2,pt3,pt4,std::back_inserter(outlist)); + W.set_color(leda_yellow); + for(vit=outlist.begin(); vit!=outlist.end(); vit++){ + W << PSR_rat.pos(*vit); + } + W.set_color(leda_black); + std::cout << outlist.size() << "\n"; + + leda_list El = PSR_rat.minimum_spanning_tree(); + std::cout << "MST:\n" << El.size() << " vertices\n"; + + W.read_mouse(); + + return 0; +} + +#endif diff --git a/Packages/Point_set_2/demo/Point_set_2/range_search.C b/Packages/Point_set_2/demo/Point_set_2/range_search.C new file mode 100644 index 00000000000..13a90b9618d --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/range_search.C @@ -0,0 +1,115 @@ +#include + +#if !defined(CGAL_USE_LEDA) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + +#include +#include +#include +#include +#include +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +leda_segment get_seg(const CGAL::Segment_2& s) +{ + CGAL::Point_2 ps=s.source(); + CGAL::Point_2 pt=s.target(); + + leda_rat_point p1(ps.x(),ps.y()), p2(pt.x(),pt.y()); + + return leda_segment(p1.to_point(),p2.to_point()); +} + +void output(leda_window& W, const CGAL::Point_set_2& PSet) +{ + W.clear(); + leda_edge e; + forall_edges(e,PSet) { + CGAL::Segment_2 s= PSet.seg(e); + W << get_seg(s); + } +} + +int main() +{ + int i; + CGAL::Point_set_2 PSet; + CGAL::Point_2 pnew; + leda_window W(600,500,leda_string("Range searches")); + CGAL::cgalize( W); + + W.init(-500,500,-400); + W.display(100,100); + + for (i=0; i<30; i++) { + W >> pnew; + PSet.insert(pnew); + output(W,PSet); + } + + for (i=0; i<5; i++) { + W >> pnew; + Vertex v = PSet.nearest_neighbor(pnew); + std::cout << "delete!\n"; std::cout.flush(); + PSet.del(v); + output(W,PSet); + } + + std::cout << "range search for circle !\n"; + CGAL::Circle_2 rc; + W >> rc; + + std::list LV; + PSet.range_search(rc,std::back_inserter(LV)); + + std::list::const_iterator it; + for (it=LV.begin();it != LV.end(); it++) + W << CGAL::GREEN << PSet.pos(*it) << CGAL::BLACK; + + std::cout << "range search for triangle !\n"; + CGAL::Point_2 pt1,pt2,pt3,pt4; + W >> pt1; + W >> pt2; + W >> pt3; + + LV.clear(); + PSet.range_search(pt1,pt2,pt3,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + W << CGAL::BLUE << PSet.pos(*it) << CGAL::BLACK; + + LV.clear(); + + std::cout << "range search for iso rectangle !\n"; + W >> pt1; // lower left + W >> pt3; // upper right + pt2 = CGAL::Point_2(pt3.x(),pt1.y()); + pt4 = CGAL::Point_2(pt1.x(),pt3.y()); + + PSet.range_search(pt1,pt2,pt3,pt4,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + W << CGAL::RED << PSet.pos(*it) << CGAL::BLACK; + + leda_list El = PSet.minimum_spanning_tree(); + Edge eakt; + + std::cout << "minimum spanning tree !\n"; + forall(eakt,El) W << CGAL::VIOLET << PSet.seg(eakt); + + W.read_mouse(); + + return 0; +} + +#endif diff --git a/Packages/Point_set_2/demo/Point_set_2/range_search_hm.C b/Packages/Point_set_2/demo/Point_set_2/range_search_hm.C new file mode 100644 index 00000000000..9d80526063b --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/range_search_hm.C @@ -0,0 +1,115 @@ +#include + +#if !defined(CGAL_USE_LEDA) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + +#include +#include +#include +#include +#include +#include + +typedef CGAL::Homogeneous REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +leda_segment get_seg(const CGAL::Segment_2& s) +{ + CGAL::Point_2 ps=s.source(); + CGAL::Point_2 pt=s.target(); + + leda_rat_point p1(ps.hx()/ps.hw(),ps.hy()/ps.hw()); + leda_rat_point p2(pt.hx()/ps.hw(),pt.hy()/ps.hw()); + + return leda_segment(p1.to_point(),p2.to_point()); +} + +void output(leda_window& W, const CGAL::Point_set_2& PSet) +{ + W.clear(); + leda_edge e; + forall_edges(e,PSet) { + CGAL::Segment_2 s = PSet.seg(e); + W << get_seg(s); + } +} + + +int main() +{ + int i; + CGAL::Point_set_2 PSet; + CGAL::Point_2 pnew; + leda_window W(600,500,leda_string("Range searches")); + CGAL::cgalize( W); + + W.init(-500,500,-400); + W.display(100,100); + + for (i=0; i<35; i++) { + W >> pnew; + PSet.insert(pnew); + output(W,PSet); + } + + for (i=0; i<5; i++) { + W >> pnew; + Vertex v = PSet.nearest_neighbor(pnew); + std::cout << "delete!\n"; std::cout.flush(); + PSet.del(v); + output(W,PSet); + } + + std::cout << "circular range search !\n"; + CGAL::Circle_2 rc; + W >> rc; + + std::list LV; + PSet.range_search(rc,std::back_inserter(LV)); + + std::list::const_iterator it; + for (it=LV.begin();it != LV.end(); it++) + W << CGAL::GREEN << PSet.pos(*it) << CGAL::BLACK; + + std::cout << "range search for triangle !\n"; + CGAL::Point_2 pt1,pt2,pt3,pt4; + W >> pt1; W >> pt2; W >> pt3; + + LV.clear(); + PSet.range_search(pt1,pt2,pt3,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + W << CGAL::BLUE << PSet.pos(*it) << CGAL::BLACK; + + LV.clear(); + + std:: cout << "rectangular range search!\n"; + W >> pt1; W >> pt3; + pt2 = CGAL::Point_2(pt3.hx()/pt3.hw(),pt1.hy()/pt3.hw()); + pt4 = CGAL::Point_2(pt1.hx()/pt3.hw(),pt3.hy()/pt3.hw()); + + PSet.range_search(pt1,pt2,pt3,pt4,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + W << CGAL::RED << PSet.pos(*it) << CGAL::BLACK; + + std::list El; + PSet.minimum_spanning_tree(std::back_inserter(El)); + std::list::const_iterator eit; + + std::cout << "minimum spanning tree !\n"; + for(eit=El.begin();eit!=El.end();eit++) + W << CGAL::VIOLET << PSet.seg(*eit); + + W.read_mouse(); + + return 0; +} +#endif diff --git a/Packages/Point_set_2/demo/Point_set_2/rs_test.C b/Packages/Point_set_2/demo/Point_set_2/rs_test.C new file mode 100644 index 00000000000..ee91fcfe0ec --- /dev/null +++ b/Packages/Point_set_2/demo/Point_set_2/rs_test.C @@ -0,0 +1,84 @@ +#include + +#if !defined(CGAL_USE_LEDA) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + +#include +#include +#include +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +int main() +{ + CGAL::Point_set_2 PSet; + CGAL::Point_2 pnew; + + std::list > Lr; + + CGAL::Point_2 p1(12,14); + CGAL::Point_2 p2(-12,14); + CGAL::Point_2 p3(2,11); + CGAL::Point_2 p4(5,6); + CGAL::Point_2 p5(6.7,3.8); + CGAL::Point_2 p6(11,20); + CGAL::Point_2 p7(-5,6); + CGAL::Point_2 p8(12,0); + CGAL::Point_2 p9(4,31); + CGAL::Point_2 p10(-10,-10); + + Lr.push_back(p1); Lr.push_back(p2); Lr.push_back(p3); + Lr.push_back(p4); Lr.push_back(p5); Lr.push_back(p6); + Lr.push_back(p7); Lr.push_back(p8); Lr.push_back(p9); + Lr.push_back(p10); + + PSet.init(Lr.begin(),Lr.end()); + + pnew= CGAL::Point_2(12,6.2); + std::cout << "insert!\n"; + PSet.insert(pnew); + + std::cout << "range search for circle !\n"; + CGAL::Circle_2 rc(p5,p6); + + std::list LV; + PSet.range_search(rc,std::back_inserter(LV)); + + std::list::const_iterator it; + for (it=LV.begin();it != LV.end(); it++) + std::cout << PSet.pos(*it) << "\n"; + + std::cout << "range search for triangle !\n"; + + LV.clear(); + PSet.range_search(p1,p2,p3,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + std::cout << PSet.pos(*it) << "\n"; + + LV.clear(); + + std::cout << "range search for iso rectangle !\n"; + CGAL::Point_2 pt1=p10; // lower left + CGAL::Point_2 pt3=p3; // upper right + + CGAL::Point_2 pt2 = CGAL::Point_2(pt3.x(),pt1.y()); + CGAL::Point_2 pt4 = CGAL::Point_2(pt1.x(),pt3.y()); + + PSet.range_search(pt1,pt2,pt3,pt4,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + std::cout << PSet.pos(*it) << "\n"; + + return 0; +} +#endif diff --git a/Packages/Point_set_2/description.txt b/Packages/Point_set_2/description.txt new file mode 100644 index 00000000000..701ca317954 --- /dev/null +++ b/Packages/Point_set_2/description.txt @@ -0,0 +1 @@ +2d Point set data type diff --git a/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2.tex b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2.tex new file mode 100644 index 00000000000..6075259e7f9 --- /dev/null +++ b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2.tex @@ -0,0 +1,374 @@ +% +------------------------------------------------------------------------+ +% | CGAL User Manual: Point_set_2.tex +% +------------------------------------------------------------------------+ + +\ccParDims + +\chapter{Point Set in 2D} +\label{chapterPoint_set_2} +\ccChapterAuthor{Matthias B\"asken} + + +%--------------------------------------------- +% Introduction +%--------------------------------------------- +\section{Introduction} + +Geometric Queries are fundamental to many applications in computational +geometry. The task is to maintain a dynamic set of geometric objects +in such a way that certain queries can be performed efficiently. +Typical examples of queries are: +find out whether a given object is contained in the set, +find all objects of the set lying in a given area (e.g. rectangle), +find the object closest to a given point or +find the pair of objects in the set lying closest to each other. +Furthermore, the set should be dynamic in the sense that deletions and +insertions of objects can be performed efficiently. + +In computational geometry literature one can find many different data structures for +maintaining sets of geometric objects. Most of them are data structures +that have been developed to support a single very special kind of query +operation. +Examples are Voronoi diagrams for answering nearest neighbor +searches, range trees for orthogonal range queries, partition trees +for more general range queries, hierarchical triangulations for point +location and segment trees for intersection queries \dots. + +In many applications, different types of queries have to be +performed on the same set of objects. A naive approach to this +problem would use a collection of the above mentioned data structures to +represent the set of objects and delegate every query operation to +the corresponding structure. +However, this is completely impractical since it uses too much +memory and requires the maintenance of all these data structures in the presence of +update operations. + +Data structures that are non-optimal in theory seem to perform quite well in +practice for many of these queries. +For example, the Delaunay diagram turns out to be a very powerful +data structure for storing dynamic sets of points under range and nearest +neighbor queries. A first implementation and computational +study of using Delaunay diagrams for geometric queries is described by +Mehlhorn and N\"aher in ~\cite{LEDAbook}. + +In this section we present a generic variant of a two dimensional point set +data type supporting various geometric queries. + +The \ccc{CGAL::Point\_set\_2} class in this section is a planar embedded bidirected +graph representing the {\em Delaunay Triangulation} of its vertex set. + +The \ccc{CGAL::Point\_set\_2} class depends on a template parameter standing for a +geometric traits class. This traits class has to provide the needed classes of +geometric objects and geometric predicates on these objects. + +\section{Examples} + +\subsection{Range search operations} + +The following example program demonstrates the various range search operations +of the two dimensional point set. +First we construct a two dimensional point set $PSet$ and initialize it with a few points. +After the $init$ - call $PSet$ is the point set of the points $p1$, ..., $p9$ . +Then we perform circular, triangular and isorectangular range search operations on the +point set. +The traits class used in the example is the standard traits class for \cgal\ kernel +objects. + +\ccHtmlLinksOff + +{\bf rs\_test.C :} +\begin{verbatim} +#include +#include +#include +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +int main() +{ + CGAL::Point_set_2 PSet; + CGAL::Point_2 pnew; + + std::list > Lr; + + CGAL::Point_2 p1(12,14); + CGAL::Point_2 p2(-12,14); + CGAL::Point_2 p3(2,11); + CGAL::Point_2 p4(5,6); + CGAL::Point_2 p5(6.7,3.8); + CGAL::Point_2 p6(11,20); + CGAL::Point_2 p7(-5,6); + CGAL::Point_2 p8(12,0); + CGAL::Point_2 p9(4,31); + CGAL::Point_2 p10(-10,-10); + + Lr.push_back(p1); Lr.push_back(p2); Lr.push_back(p3); + Lr.push_back(p4); Lr.push_back(p5); Lr.push_back(p6); + Lr.push_back(p7); Lr.push_back(p8); Lr.push_back(p9); + Lr.push_back(p10); + + PSet.init(Lr.begin(),Lr.end()); + + pnew= CGAL::Point_2(12,6.2); + std::cout << "insert!\n"; + PSet.insert(pnew); + + std::cout << "range search for circle !\n"; + CGAL::Circle_2 rc(p5,p6); + + std::list LV; + PSet.range_search(rc,std::back_inserter(LV)); + + std::list::const_iterator it; + for (it=LV.begin();it != LV.end(); it++) + std::cout << PSet.pos(*it) << "\n"; + + std::cout << "range search for triangle !\n"; + + LV.clear(); + PSet.range_search(p1,p2,p3,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + std::cout << PSet.pos(*it) << "\n"; + + LV.clear(); + + std::cout << "range search for iso rectangle !\n"; + CGAL::Point_2 pt1=p10; // lower left + CGAL::Point_2 pt3=p3; // upper right + + CGAL::Point_2 pt2 = CGAL::Point_2(pt3.x(),pt1.y()); + CGAL::Point_2 pt4 = CGAL::Point_2(pt1.x(),pt3.y()); + + PSet.range_search(pt1,pt2,pt3,pt4,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + std::cout << PSet.pos(*it) << "\n"; + + return 0; +} +\end{verbatim} + +\ccHtmlLinksOn + + +\subsection{Minimum spanning tree and k nearest neighbor search operation} + +The next example program demonstrates the $k$ nearest neighbors operation +and the computation of the minimum spanning tree. +This demonstration program uses the $GeoWin$ library for visualization. + + +\ccHtmlLinksOff + +{\bf geowin\_k\_nearest\_neighbors.C :} +\begin{verbatim} +#include +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +CGAL::Point_set_2 PST; +int k; + +class construct_pointset : public geowin_update >, + std::list > > +{ +public: + void update(const std::list >& Lin, + std::list >& Lout) + { + PST.init(Lin.begin(),Lin.end()); + Lout.clear(); + PST.segments(std::back_inserter(Lout)); + } +}; + +class mst : public geowin_update >, + std::list > > +{ +public: + void update(const std::list >& Lin, + std::list >& Lout) + { + Lout.clear(); + std::list output; + std::list::const_iterator pit; + + PST.minimum_spanning_tree( std::back_inserter(output)); + + for (pit=output.begin(); pit != output.end(); pit++){ + Lout.push_back(CGALSegment(PST.seg(*pit))); + } + } +}; + +class nearest_neighbors : public geowin_update >, + std::list > > +{ +public: + void update(const std::list >& Lin, + std::list >& Lout) + { + Lout.clear(); + std::list >::const_iterator it = Lin.begin(); + std::list output; + std::list::const_iterator pit; + + for (; it != Lin.end(); it++){ + PST.nearest_neighbors(*it, k, std::back_inserter(output)); + } + for (pit=output.begin(); pit != output.end(); pit++){ + Lout.push_back(CGALCircle(PST.pos(*pit),2.0)); + } + } +}; + +int main() +{ + geowin_init_default_type((std::list >*)0, + leda_string("CGALPointlist")); + + std::cout << "Find the k nearest neighbors of every point in scene 2.\n"; + std::cout << "k:"; std::cin >> k; + + GeoWin gw; + + std::list > Lp; + geo_scene sc1 = gw.new_scene(Lp); + + std::list > Lother; + geo_scene sc2 = gw.new_scene(Lother); + gw.set_color(sc2,leda_blue); + + construct_pointset CP; + geo_scene sc3 = gw.new_scene(CP, sc1, leda_string("2d point set")); + gw.set_color(sc3,leda_blue); + + nearest_neighbors NN; + geo_scene sc4 = gw.new_scene(NN, sc2, leda_string("k nearest neighbors")); + gw.set_fill_color(sc4,leda_red); + gw.set_color(sc4,leda_red); + gw.set_point_style(sc4,leda_circle_point); + gw.set_line_width(sc4,4); + + mst MS; + geo_scene sc5 = gw.new_scene(MS, sc1, leda_string("Minimum spanning tree")); + gw.set_line_width(sc5,2); + + gw.set_all_visible(true); + gw.add_dependence(sc1,sc4); + + gw.edit(sc1); + + return 0; +} +\end{verbatim} + + +\ccHtmlLinksOn + +\subsection{Using the LEDA kernel} + +We provide also traits classes for the \leda\ floating point and rational kernels. The next short +example demonstrates the usage of the two dimensional point set with the rational \leda\ kernel. + +\ccHtmlLinksOff + +\begin{verbatim} +#include +#include +#include +#include + + +typedef CGAL::point_set_leda_rat_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +void output(leda_window& W, const CGAL::Point_set_2& PSR_rat) +{ + W.clear(); + leda_edge e; + forall_edges(e,PSR_rat) W << leda_segment(PSR_rat.seg(e).to_segment()); +} + +int main() +{ + int i; + CGAL::Point_set_2 PSR_rat; + leda_window W(500,400); + W.init(-500,500,-400); + W.display(); + + // insert operation + for (i=0; i<30; i++) { + leda_rat_point pnew; + W >> pnew; + PSR_rat.insert(pnew); + output(W,PSR_rat); + } + + // delete operation + for (i=0; i<3; i++) { + leda_rat_point pnew; + W >> pnew; + Vertex v = PSR_rat.nearest_neighbor(pnew); + PSR_rat.del(v); + output(W,PSR_rat); + } + + W.set_point_style(leda_disc_point); + + leda_rat_circle rc; + W >> rc; W << rc; + + leda_list LV; + + // circular range search + PSR_rat.range_search(rc, std::back_inserter(LV)); + Vertex v; + W.set_color(leda_red); + forall(v,LV) W << PSR_rat.pos(v); + + leda_rat_point pt1,pt2,pt3,pt4; + W >> pt1; W << pt1; + W >> pt2; W << pt2; + W >> pt3; W << pt3; + + LV.clear(); + + // triangular range search + PSR_rat.range_search(pt1,pt2,pt3,std::back_inserter(LV)); + leda_list::iterator it; + W.set_color(leda_green); + + for (it=LV.begin();it != LV.end(); it++) + W << PSR_rat.pos(*it); + + LV.clear(); + + W >> pt1; W << pt1; + W >> pt3; W << pt3; + + pt2 = leda_rat_point(pt3.xcoord(),pt1.ycoord()); + pt4 = leda_rat_point(pt1.xcoord(),pt3.ycoord()); + + W.set_color(leda_orange); + + // iso rectangular range search + PSR_rat.range_search(pt1,pt2,pt3,pt4,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + W << PSR_rat.pos(*it); + + W.read_mouse(); + return 1; +} +\end{verbatim} + +\ccHtmlLinksOn diff --git a/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/Point_set_2.tex b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/Point_set_2.tex new file mode 100644 index 00000000000..2a7bb5316be --- /dev/null +++ b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/Point_set_2.tex @@ -0,0 +1,290 @@ +% +----------------------------------------------------------+ +%--------------------------------------------- +% Point_set_2 data type +%--------------------------------------------- +\begin{ccRefClass}{Point_set_2} + +\ccDefinition + +\ccInclude{CGAL/Point_set_2.h} + +An instance $T$ of data type \ccRefName\ is a planar embedded bidirected +graph representing the {\em Delaunay Triangulation} of its vertex set. +The position of a vertex $v$ is given by $T.pos(v)$ and we use +$S = \{ T.pos(v) \mid v \in T \}$ to denote the underlying point set. +Each face of $T$ (except for the outer face) is a triangle whose +circumscribing circle does not contain any point of $S$ in its interior. +For every edge $e$, the sequence +\[e, T.face\_cycle\_succ(e), T.face\_cycle\_succ(T.face\_cycle\_succ(e)),\ldots\] +traces the boundary of the face to the left of $e$. +The edges of the outer face of $T$ form the convex hull of $S$; the trace of +the convex hull is clockwise. +The subgraph obtained from $T$ by removing all diagonals of +co-circular quadrilaterals is called the {\em Delaunay Diagram} +of $S$. + +The class \ccRefName\ provides operations for inserting and deleting points, +point location, nearest neighbor searches, and navigation in both +the triangulation and the diagram. + +Note that the \ccRefName\ is derived from the \leda\ GRAPH class +(Parameterized Graphs). That means that it provides all constant +graph operations (like $reversal$, $all\_edges$, ...). +See the \leda\ user manual or \leda\ book ~\cite{LEDAbook} for more details. + +Be aware that the nearest neighbor queries for a point (not for a node) and +the range search queries for circles, triangles, and rectangles are non-const +operations and modify the underlying graph. The set of nodes and edges is +not changed; however, it is not guaranteed that the underlying Delaunay +triangulation is unchanged. + +The \ccRefName\ class of \cgal\ depends on a template parameter standing for a +geometric traits class. This traits class has to provide the geometric objects needed +in \ccRefName\ and geometric predicates on these objects. +\ccCreationVariable{T} + + +\ccHtmlLinksOff + + +\ccTypes +\ccThree{typedef Traits::Point Point;}{the point type}{} +\ccThreeToTwo +\ccTypedef{typedef Traits::Point Point;}{the point type}{} +\ccTypedef{typedef Traits::Segment Segment;}{the segment type} +\ccTypedef{typedef Traits::Circle Circle;}{the circle type} +\ccTypedef{typedef Traits::Line Line;}{the line type} +\ccTypedef{typedef Traits::FT Numb_type;}{the field type of the representation class} +\ccNestedType{Vertex}{the vertex type.} +\ccNestedType{Edge}{the edge type.} + + +\ccHtmlLinksOn + + +\ccCreation + +\ccConstructor{Point_set_2();} +{creates an empty \ccRefName\ .} + +\ccConstructor{Point_set_2(const std::list& S);} +{creates a \ccRefName\ \ccVar\ of the points in $S$. +If $S$ contains multiple occurrences of points only the last +occurrence of each point is retained.} + +\ccConstructor{template +Point_set_2d(InputIterator first, InputIterator last);} +{creates a \ccRefName\ \ccVar\ of the points in the range +[$first$,$last$).} + + +\ccOperations + +\ccMethod{void init(const std::list& L);} +{ makes \ccVar\ a \ccRefName\ for the points in $L$.} + +\ccMethod{template +void init(InputIterator first, InputIterator last);} +{ makes \ccVar\ a \ccRefName\ for the points in the range +[$first$,$last$).} + +\ccMethod{template +OutputIterator points(OutputIterator out);} +{ places all points of \ccVar as a sequence of objects of type +$Point$ in a container of value type of $out$, +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence.} + +\ccMethod{template +OutputIterator segments(OutputIterator out);} +{ places all segments of \ccVar\ as a sequence of objects of type +$Segment$ in a container of value type of $out$, +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence.} + +\ccHtmlLinksOff + +\ccMethod{template +OutputIterator vertices(OutputIterator out);} +{ places all vertices of \ccVar\ as a sequence of objects of type +Vertex in a container of value type of $out$, +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence.} + +\ccHtmlLinksOn + + +\ccMethod{template +OutputIterator edges(OutputIterator out);} +{ places all points of \ccVar\ as a sequence of objects of type +$Edge$ in a container of value type of $out$, +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence.} + +\ccMethod{Edge d_face_cycle_succ(Edge e);} +{ returns the face cycle successor of $e$ in the Delaunay diagram +of \ccVar . \ccPrecond $e$ belongs to the Delaunay diagram.} + +\ccMethod{Edge d_face_cycle_pred(Edge e);} +{ returns the face cycle predecessor of $e$ in the Delaunay diagram +of \ccVar. \ccPrecond $e$ belongs to the Delaunay diagram.} + +\ccMethod{bool is_empty();} +{ decides whether \ccVar\ is empty. } + +\ccMethod{void clear();} +{ makes \ccVar\ empty. } + +\ccMethod{Edge locate(Point p);} +{ returns an edge $e$ of \ccVar\ that contains $p$ or that +borders the face that contains $p$. In the former case, +a hull edge is returned if $p$ lies on the boundary of the convex hull. +In the latter case we have $T.orientation(e,p) > 0$ except if all points of +$T$ are collinear and +$p$ lies on the induced line. In this case $target(e)$ is visible from +$p$. The function returns $NULL$ if $T$ has no edge.} + + +\ccHtmlLinksOff + +\ccMethod{Vertex lookup(Point p);} +{ if \ccVar\ contains a Vertex $v$ with $|pos(v)| = p$ +the result is $v$ otherwise the result is $NULL$. } + +\ccMethod{Vertex insert(Point p);} +{ inserts point $p$ into \ccVar\ and returns the corresponding vertex. +More precisely, if there is already a vertex $v$ in \ccVar\ positioned +at $p$ then $pos(v)$ is made identical to $p$ and if there is no +such node then a new node $v$ with $pos(v) = p$ is added to $T$. +In either case, $v$ is returned.} + +\ccMethod{void del(Vertex v);} +{ removes the vertex $v$ from \ccVar. \ccPrecond v is a vertex in \ccVar.} + +\ccMethod{void del(Point p);} +{ removes the vertex $v$ with position $p$ from \ccVar. If there is +no such vertex in \ccVar, the function returns without changing \ccVar. } + +\ccMethod{Vertex nearest_neighbor(Point p);} +{ computes a vertex $v$ of \ccVar\ that is closest to $p$. +If \ccVar\ is empty, $NULL$ is returned. +This is a non-const operation.} + +\ccMethod{Vertex nearest_neighbor(Vertex v);} +{ computes a vertex $w$ of \ccVar\ that is closest to $v$. +If $v$ is the only vertex in \ccVar\ , $NULL$ is returned. +\ccPrecond $v$ is a vertex in \ccVar.} + +\ccMethod{template +OutputIterator nearest_neighbors(Point p, int k, OutputIterator res);} +{ computes the $k$ nearest neighbors of $p$, and places them as a sequence of objects of type +Vertex in a container of value type of $res$ +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence. } + +\ccMethod{template +OutputIterator nearest_neighbors(Vertex v, int k,OutputIterator res);} +{ computes the $k$ nearest neighbors of $v$, and places them as a sequence of objects of type +Vertex in a container of value type of $res$ +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence. } + +\ccMethod{template +OutputIterator range_search(const Circle& C, OutputIterator res);} +{ computes all vertices contained in the closure of disk $C$. +\ccPrecond $C$ must be a proper circle (not a straight line). +The computed vertices will be placed as a sequence of objects in a container of value type +of $res$ +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence. +This is a non-const operation.} + +\ccMethod{template +OutputIterator range_search(const Point& a, const Point& b, const Point& c,OutputIterator res);} +{ computes all vertices contained in the closure of the triangle $(a,b,c)$.\\ +\ccPrecond $a$, $b$, and $c$ must not be collinear. +The computed vertices will be placed as a sequence of objects in a container of value type +of $res$ +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence. +This is a non-const operation.} + +\ccMethod{template +OutputIterator range_search(const Point& a1, const Point& b1, const Point& c1,const Point& +d1,OutputIterator res);} +{ computes all vertices contained in the closure of the iso-rectangle $(a1,b1,c1,d1)$.\\ +\ccPrecond $a1$ is the lower left point, $b1$ the lower right, $c1$ the upper +right and $d1$ the upper left point of the iso rectangle. +The computed vertices will be placed as a sequence of objects in a container of value type +of $res$ +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence. +This is a non-const operation.} + +\ccMethod{template +OutputIterator minimum_spanning_tree(OutputIterator result);} +{ places all edges of the minimum spanning tree of \ccVar\ as a sequence of objects of type +$Edge$ in a container of type corresponding to the type of $out$ +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence.} + +\ccMethod{bool is_non_diagram_edge(Edge e);} +{ checks whether $e$ is a non-diagram edge. } + +\ccMethod{Point pos(Vertex v);} +{ returns the position of $v$ in \ccVar.} + +\ccMethod{Vertex source(Edge e);} +{ returns the source vertex of $e$.} + +\ccMethod{Vertex target(Edge e);} +{ returns the target vertex of $e$.} + +\ccMethod{Point pos_source(Edge e);} +{ returns the position of the source of $e$ in \ccVar.} + +\ccMethod{Point pos_target(Edge e);} +{ returns the position of the target of $e$ in \ccVar.} + +\ccMethod{Segment seg(Edge e);} +{ returns the line segment corresponding to edge $e$ starting +at $pos\_source(e)$.} + +\ccMethod{Line supporting_line(Edge e);} +{ returns the supporting line of edge $e$.} + +\ccMethod{int orientation(Edge e, Point p);} +{ returns $orientation(T.pos\_source(e),T.pos\_target(e),p)$.} + +\ccMethod{Edge get_hull_edge();} +{ returns an edge of the outer face of \ccVar\ (i.e., an edge of the convex hull). } + +\ccMethod{bool is_diagram_edge(Edge e);} +{returns true if $e$ is an edge of the Delaunay diagram, i.e., either +an edge on the convex hull or an edge where the incident triangles have +distinct circumcircles.} + +\ccMethod{bool is_hull_edge(Edge e);} +{returns true if $e$ is an edge of the convex hull of \ccVar, i.e., +an edge on the face cycle of the outer face. } + +\ccHtmlLinksOn + +\ccMethod{int dim();} +{returns $-1$ if \ccVar\ is empty, returns $0$ if \ccVar +consists of only one point, +returns $1$ if \ccVar\ consists of at least two points +and all points in \ccVar\ +are collinear, and returns $2$ otherwise.} + +\end{ccRefClass} diff --git a/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/Point_set_traits.tex b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/Point_set_traits.tex new file mode 100644 index 00000000000..093a1593924 --- /dev/null +++ b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/Point_set_traits.tex @@ -0,0 +1,114 @@ +\begin{ccRefConcept} {Point_set_traits} + +\subsection{Requirements for the Point\_set traits class} + +A point set traits class has to provide some primitives that are used by the point set class. +The following catalog lists the involved primitives. +The types used in the traits class must have a copy constructor and an assignment operator. + +\ccCreationVariable{ps_traits} +\ccTypes + +\ccNestedType{FT}% + {The field type of the representation class of the point, segment, circle and line types.} + +\ccNestedType{Point}% + {The point type on which the point set operates.} + +\ccNestedType{Circle}% + {The circle type on which the point set operates.} + + +\ccHtmlLinksOff + +\ccNestedType{Line}% + {The line type on which the point set operates.} + +\ccHtmlLinksOn + +\ccNestedType{Segment}% + {The segment type on which the point set operates.} + +\ccNestedType{Compare_xy_2}% + {The primitive must provide + \ccc{int operator()(const Point& p1,const Point& p2) const} + and has to be derived from $leda\_cmp\_base$. + The operator has to compare the points $p1$ and $p2$ lexicographically in + $xy$ order. If $p1$ is smaller, the operator has to return -1, if $p1$ + is larger, the operator has to return 1, 0 otherwise. + } + +\ccNestedType{Compare_dist_2}% + {The primitive must provide + \ccc{Comparison_result operator()(const Point& p1,const Point& p2, const Point& p3) const}. + The operator has to compare the distances of points $p2$ and $p3$ to $p1$. + The operator returns \ccc{SMALLER}, if $p2$ is closer (to $p1$), \ccc{LARGER} if $p3$ is closer, + \ccc{EQUAL} otherwise. + } + + \ccNestedType{Orientation}% + {The primitive must provide + \ccc{Orientation operator()(const Point& p1,const Point& p2,const Point& p3) const}. + This operator has to return \ccc{COLLINEAR} if the 3 points are collinear, + \ccc{LEFTTURN} if $p3$ lies on the left of the directed line through $p1$ and $p2$, + \ccc{RIGHTTURN} otherwise. + } + + \ccNestedType{Side_of_oriented_circle_2}% + {The primitive must provide + \ccc{Oriented_side operator()(const Point& p1,const Point& p2,const Point& p3, const Point& p4) const}. + This operator has to return \ccc{ON_POSITIVE_SIDE} if $p4$ lies on the positive side of the circle through + the points $p1$,$p2$ and $p3$, \ccc{ON_NEGATIVE_SIDE} if $p4$ lies on the negative side of the circle, + \ccc{ON_ORIENTED_BOUNDARY} otherwise. + } + + \ccNestedType{Side_of_halfspace_2}% + {The primitive must provide + \ccc{Orientation operator()(const Point& a,const Point& b, const Point& p3) const }. + This operator has to return \ccc{LEFTTURN} if $p3$ lies in the open halfspace $h$ orthogonal to vector + $b-a$ containing $b$ and having $a$ on its boundary, \ccc{COLLINEAR} if $p3$ is on the boundary of $h$ and + \ccc{RIGHTTURN} otherwise. + } + + \ccNestedType{Segment_has_on_2}% + {The primitive must provide + \ccc{bool operator()(const Segment& seg, const Point& p) const }. + This operator has to return true if $seg$ contains $p$, false otherwise.} + + \ccNestedType{Squared_distance}% + {The primitive must provide + \ccc{FT operator()(const Point& p1,const Point& p2) const}. + The operator has to return the squared distance from $p1$ to $p2$.} + + \ccNestedType{Squared_distance_to_line}% + {The primitive must provide + \ccc{FT operator()(const Line& l,const Point& p) const}. + The operator has to return the squared distance from $l$ to $p$.} + + \ccNestedType{Circle_bounded_side_2}% + {The primitive must provide + \ccc{Bounded_side operator()(const Circle& c, const Point& p) const}. + The operator has to return \ccc{ON_BOUNDED_SIDE} if $p$ lies on the bounded side of $c$, + \ccc{ON_UNBOUNDED_SIDE} if $p$ lies on the unbounded side of $c$, \ccc{ON_BOUNDARY} otherwise.} + + \ccNestedType{Circle_center_2}% + {The primitive must provide + \ccc{Point operator()(const Circle& c) const}. + The operator has to return the center of $c$.} + + \ccNestedType{Construct_circle_2}% + {This primitive constructs a circle. It must provide + \ccc{Circle operator()(const Point& p1,const Point& p2, const Point& p3) const }. + The points $p1$, $p2$ and $p3$ are on the boundary.} + + \ccNestedType{Construct_segment_2}% + {This primitive constructs a segment. It must provide + \ccc{Segment operator()(const Point& p1,const Point& p2) const}. + Point $p1$ is the source of the segment, $p2$ the target.} + + \ccNestedType{Construct_line_2}% + {This primitive constructs a line. It must provide + \ccc{Line operator()(const Point& p1,const Point& p2) const}. + The line is constructed through $p1$ and $p2$.} + +\end{ccRefConcept} diff --git a/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/cgal.bib b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/cgal.bib new file mode 100644 index 00000000000..491f08aa94b --- /dev/null +++ b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/cgal.bib @@ -0,0 +1,17 @@ +@Book{LEDAbook, + author + = + "K. Mehlhorn and S. N\"aher", + title + = + "LEDA -- A platform for combnatorial and geometric computing", + publisher + = + "Cambridge University Press", + + year + = + "1999", + +} + diff --git a/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/intro.tex b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/intro.tex new file mode 100644 index 00000000000..f15c2250bd0 --- /dev/null +++ b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/intro.tex @@ -0,0 +1,26 @@ +% +------------------------------------------------------------------------+ +% | CGAL Reference Manual: Point_set_2.tex +% +------------------------------------------------------------------------+ + + +\ccParDims + +\clearpage +\section{Reference pages for Point Set in 2D} + +\section*{Summary} + +The two dimensional point set is a class for geometric queries. +It supports circular, triangular and iso rectangular range searches, +nearest neighbor searches and the computation of the minimum spanning tree. +The point set is a dynamic data structure supporting the insertion and +deletion of points. + +\subsection*{Concepts} +\ccc{Point_set_traits}\\ + +\subsection*{Classes} +\ccc{CGAL::Point_set_2}\\ +\ccc{CGAL::point_set_traits_2}\\ +\ccc{CGAL::point_set_leda_float_traits_2}\\ +\ccc{CGAL::point_set_leda_rat_traits_2}\\ diff --git a/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/main.tex b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/main.tex new file mode 100644 index 00000000000..32d2b0163f0 --- /dev/null +++ b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/main.tex @@ -0,0 +1,15 @@ +% +------------------------------------------------------------------------+ +% | CGAL Reference Manual: main.tex +% +------------------------------------------------------------------------+ +% | Point_set_2 +% | +% +------------------------------------------------------------------------+ + +\input{Point_set_2_ref/intro} +\input{Point_set_2_ref/Point_set_2} +\input{Point_set_2_ref/Point_set_traits} +\input{Point_set_2_ref/point_set_traits_2} +\input{Point_set_2_ref/point_set_leda_float_traits_2} +\input{Point_set_2_ref/point_set_leda_rat_traits_2} + +%% EOF %% diff --git a/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/point_set_leda_float_traits_2.tex b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/point_set_leda_float_traits_2.tex new file mode 100644 index 00000000000..c6ffd76d533 --- /dev/null +++ b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/point_set_leda_float_traits_2.tex @@ -0,0 +1,35 @@ +\begin{ccRefClass}{point_set_leda_float_traits_2} +\subsubsection{Traits classes for \leda\ 2D Points} + +\ccInclude{CGAL/point_set_leda_traits_2.h} + +The traits class \ccc{point_set_leda_float_traits_2} deals with \leda\ 2D float kernel objects. + +\ccTypes +\ccThree{typedef ttttttttttttttttttttt}{tttttttttt}{} +\ccThreeToTwo +\ccTypedef{typedef double FT;}{} +\ccTypedef{typedef leda_point Point;}{} +\ccTypedef{typedef leda_segment Segment;}{} + +\ccHtmlLinksOff + +\ccTypedef{typedef leda_line Line;}{} + +\ccHtmlLinksOn + +\ccTypedef{typedef leda_circle Circle;}{} +\ccNestedType{Compare_xy_2}{} +\ccNestedType{Compare_dist_2}{} +\ccNestedType{Orientation}{} +\ccNestedType{Side_of_oriented_circle_2}{} +\ccNestedType{Side_of_halfspace_2}{} +\ccNestedType{Segment_has_on_2}{} +\ccNestedType{Squared_distance}{} +\ccNestedType{Squared_distance_to_line}{} +\ccNestedType{Circle_bounded_side_2}{} +\ccNestedType{Circle_center_2}{} +\ccNestedType{Construct_circle_2}{} +\ccNestedType{Construct_segment_2}{} +\ccNestedType{Construct_line_2}{} +\end{ccRefClass} diff --git a/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/point_set_leda_rat_traits_2.tex b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/point_set_leda_rat_traits_2.tex new file mode 100644 index 00000000000..09c4cbccfec --- /dev/null +++ b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/point_set_leda_rat_traits_2.tex @@ -0,0 +1,35 @@ +\begin{ccRefClass}{point_set_leda_rat_traits_2} + +The traits class \ccc{point_set_leda_rat_traits_2} deals with \leda\ 2D rational kernel objects. + +\ccTypes +\ccThree{typedef ttttttttttttttttttttttt}{tttttttttt}{} +\ccThreeToTwo +\ccTypedef{typedef leda_rational FT;}{} +\ccTypedef{typedef leda_rat_point Point;}{} +\ccTypedef{typedef leda_rat_segment Segment;}{} + +\ccHtmlLinksOff + +\ccTypedef{typedef leda_rat_line Line;}{} + +\ccHtmlLinksOn + +\ccTypedef{typedef leda_rat_circle Circle;}{} +\ccNestedType{Compare_xy_2}{} +\ccNestedType{Compare_dist_2}{} +\ccNestedType{Orientation}{} +\ccNestedType{Side_of_oriented_circle_2}{} +\ccNestedType{Side_of_halfspace_2}{} +\ccNestedType{Segment_has_on_2}{} +\ccNestedType{Squared_distance}{} +\ccNestedType{Squared_distance_to_line}{} +\ccNestedType{Circle_bounded_side_2}{} +\ccNestedType{Circle_center_2}{} +\ccNestedType{Construct_circle_2}{} +\ccNestedType{Construct_segment_2}{} +\ccNestedType{Construct_line_2}{} +\end{ccRefClass} + + +\ccParDims diff --git a/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/point_set_traits_2.tex b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/point_set_traits_2.tex new file mode 100644 index 00000000000..5003383739c --- /dev/null +++ b/Packages/Point_set_2/doc_tex/Point_set_2/Point_set_2_ref/point_set_traits_2.tex @@ -0,0 +1,36 @@ +\begin{ccRefClass}{point_set_traits_2} +\subsubsection{Traits class for \cgal\ 2D kernel objects} + +\ccInclude{CGAL/point_set_traits_2.h} + +The traits class \ccRefName\ deals with \cgal\ 2D kernel objects. + +\ccTypes +\ccThree{typedef ttttttttttttttttttttt}{tttttttttt}{} +\ccThreeToTwo +\ccTypedef{typedef T::FT FT;}{} +\ccTypedef{typedef Point_2 Point;}{} +\ccTypedef{typedef Segment_2 Segment;}{} + +\ccHtmlLinksOff + +\ccTypedef{typedef Line_2 Line;}{} + +\ccHtmlLinksOn + +\ccTypedef{typedef Circle_2 Circle;}{} +\ccNestedType{Compare_xy_2}{} +\ccNestedType{Compare_dist_2}{} +\ccNestedType{Orientation}{} +\ccNestedType{Side_of_oriented_circle_2}{} +\ccNestedType{Side_of_halfspace_2}{} +\ccNestedType{Segment_has_on_2}{} +\ccNestedType{Squared_distance}{} +\ccNestedType{Squared_distance_to_line}{} +\ccNestedType{Circle_bounded_side_2}{} +\ccNestedType{Circle_center_2}{} +\ccNestedType{Construct_circle_2}{} +\ccNestedType{Construct_segment_2}{} +\ccNestedType{Construct_line_2}{} + +\end{ccRefClass} diff --git a/Packages/Point_set_2/doc_tex/Point_set_2/cgal.bib b/Packages/Point_set_2/doc_tex/Point_set_2/cgal.bib new file mode 100644 index 00000000000..491f08aa94b --- /dev/null +++ b/Packages/Point_set_2/doc_tex/Point_set_2/cgal.bib @@ -0,0 +1,17 @@ +@Book{LEDAbook, + author + = + "K. Mehlhorn and S. N\"aher", + title + = + "LEDA -- A platform for combnatorial and geometric computing", + publisher + = + "Cambridge University Press", + + year + = + "1999", + +} + diff --git a/Packages/Point_set_2/doc_tex/Point_set_2/main.tex b/Packages/Point_set_2/doc_tex/Point_set_2/main.tex new file mode 100644 index 00000000000..840d0ed0968 --- /dev/null +++ b/Packages/Point_set_2/doc_tex/Point_set_2/main.tex @@ -0,0 +1,12 @@ +% +------------------------------------------------------------------------+ +% | CGAL Reference Manual: main.tex +% +------------------------------------------------------------------------+ +% | Point_set_2 +% | +% | 15.10.1999 Matthias Baesken +% +------------------------------------------------------------------------+ + +\input{Point_set_2} +\input{Point_set_2_ref/main} + +%% EOF %% diff --git a/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2.tex b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2.tex new file mode 100644 index 00000000000..6075259e7f9 --- /dev/null +++ b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2.tex @@ -0,0 +1,374 @@ +% +------------------------------------------------------------------------+ +% | CGAL User Manual: Point_set_2.tex +% +------------------------------------------------------------------------+ + +\ccParDims + +\chapter{Point Set in 2D} +\label{chapterPoint_set_2} +\ccChapterAuthor{Matthias B\"asken} + + +%--------------------------------------------- +% Introduction +%--------------------------------------------- +\section{Introduction} + +Geometric Queries are fundamental to many applications in computational +geometry. The task is to maintain a dynamic set of geometric objects +in such a way that certain queries can be performed efficiently. +Typical examples of queries are: +find out whether a given object is contained in the set, +find all objects of the set lying in a given area (e.g. rectangle), +find the object closest to a given point or +find the pair of objects in the set lying closest to each other. +Furthermore, the set should be dynamic in the sense that deletions and +insertions of objects can be performed efficiently. + +In computational geometry literature one can find many different data structures for +maintaining sets of geometric objects. Most of them are data structures +that have been developed to support a single very special kind of query +operation. +Examples are Voronoi diagrams for answering nearest neighbor +searches, range trees for orthogonal range queries, partition trees +for more general range queries, hierarchical triangulations for point +location and segment trees for intersection queries \dots. + +In many applications, different types of queries have to be +performed on the same set of objects. A naive approach to this +problem would use a collection of the above mentioned data structures to +represent the set of objects and delegate every query operation to +the corresponding structure. +However, this is completely impractical since it uses too much +memory and requires the maintenance of all these data structures in the presence of +update operations. + +Data structures that are non-optimal in theory seem to perform quite well in +practice for many of these queries. +For example, the Delaunay diagram turns out to be a very powerful +data structure for storing dynamic sets of points under range and nearest +neighbor queries. A first implementation and computational +study of using Delaunay diagrams for geometric queries is described by +Mehlhorn and N\"aher in ~\cite{LEDAbook}. + +In this section we present a generic variant of a two dimensional point set +data type supporting various geometric queries. + +The \ccc{CGAL::Point\_set\_2} class in this section is a planar embedded bidirected +graph representing the {\em Delaunay Triangulation} of its vertex set. + +The \ccc{CGAL::Point\_set\_2} class depends on a template parameter standing for a +geometric traits class. This traits class has to provide the needed classes of +geometric objects and geometric predicates on these objects. + +\section{Examples} + +\subsection{Range search operations} + +The following example program demonstrates the various range search operations +of the two dimensional point set. +First we construct a two dimensional point set $PSet$ and initialize it with a few points. +After the $init$ - call $PSet$ is the point set of the points $p1$, ..., $p9$ . +Then we perform circular, triangular and isorectangular range search operations on the +point set. +The traits class used in the example is the standard traits class for \cgal\ kernel +objects. + +\ccHtmlLinksOff + +{\bf rs\_test.C :} +\begin{verbatim} +#include +#include +#include +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +int main() +{ + CGAL::Point_set_2 PSet; + CGAL::Point_2 pnew; + + std::list > Lr; + + CGAL::Point_2 p1(12,14); + CGAL::Point_2 p2(-12,14); + CGAL::Point_2 p3(2,11); + CGAL::Point_2 p4(5,6); + CGAL::Point_2 p5(6.7,3.8); + CGAL::Point_2 p6(11,20); + CGAL::Point_2 p7(-5,6); + CGAL::Point_2 p8(12,0); + CGAL::Point_2 p9(4,31); + CGAL::Point_2 p10(-10,-10); + + Lr.push_back(p1); Lr.push_back(p2); Lr.push_back(p3); + Lr.push_back(p4); Lr.push_back(p5); Lr.push_back(p6); + Lr.push_back(p7); Lr.push_back(p8); Lr.push_back(p9); + Lr.push_back(p10); + + PSet.init(Lr.begin(),Lr.end()); + + pnew= CGAL::Point_2(12,6.2); + std::cout << "insert!\n"; + PSet.insert(pnew); + + std::cout << "range search for circle !\n"; + CGAL::Circle_2 rc(p5,p6); + + std::list LV; + PSet.range_search(rc,std::back_inserter(LV)); + + std::list::const_iterator it; + for (it=LV.begin();it != LV.end(); it++) + std::cout << PSet.pos(*it) << "\n"; + + std::cout << "range search for triangle !\n"; + + LV.clear(); + PSet.range_search(p1,p2,p3,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + std::cout << PSet.pos(*it) << "\n"; + + LV.clear(); + + std::cout << "range search for iso rectangle !\n"; + CGAL::Point_2 pt1=p10; // lower left + CGAL::Point_2 pt3=p3; // upper right + + CGAL::Point_2 pt2 = CGAL::Point_2(pt3.x(),pt1.y()); + CGAL::Point_2 pt4 = CGAL::Point_2(pt1.x(),pt3.y()); + + PSet.range_search(pt1,pt2,pt3,pt4,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + std::cout << PSet.pos(*it) << "\n"; + + return 0; +} +\end{verbatim} + +\ccHtmlLinksOn + + +\subsection{Minimum spanning tree and k nearest neighbor search operation} + +The next example program demonstrates the $k$ nearest neighbors operation +and the computation of the minimum spanning tree. +This demonstration program uses the $GeoWin$ library for visualization. + + +\ccHtmlLinksOff + +{\bf geowin\_k\_nearest\_neighbors.C :} +\begin{verbatim} +#include +#include + +typedef CGAL::Cartesian REP; +typedef CGAL::point_set_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +CGAL::Point_set_2 PST; +int k; + +class construct_pointset : public geowin_update >, + std::list > > +{ +public: + void update(const std::list >& Lin, + std::list >& Lout) + { + PST.init(Lin.begin(),Lin.end()); + Lout.clear(); + PST.segments(std::back_inserter(Lout)); + } +}; + +class mst : public geowin_update >, + std::list > > +{ +public: + void update(const std::list >& Lin, + std::list >& Lout) + { + Lout.clear(); + std::list output; + std::list::const_iterator pit; + + PST.minimum_spanning_tree( std::back_inserter(output)); + + for (pit=output.begin(); pit != output.end(); pit++){ + Lout.push_back(CGALSegment(PST.seg(*pit))); + } + } +}; + +class nearest_neighbors : public geowin_update >, + std::list > > +{ +public: + void update(const std::list >& Lin, + std::list >& Lout) + { + Lout.clear(); + std::list >::const_iterator it = Lin.begin(); + std::list output; + std::list::const_iterator pit; + + for (; it != Lin.end(); it++){ + PST.nearest_neighbors(*it, k, std::back_inserter(output)); + } + for (pit=output.begin(); pit != output.end(); pit++){ + Lout.push_back(CGALCircle(PST.pos(*pit),2.0)); + } + } +}; + +int main() +{ + geowin_init_default_type((std::list >*)0, + leda_string("CGALPointlist")); + + std::cout << "Find the k nearest neighbors of every point in scene 2.\n"; + std::cout << "k:"; std::cin >> k; + + GeoWin gw; + + std::list > Lp; + geo_scene sc1 = gw.new_scene(Lp); + + std::list > Lother; + geo_scene sc2 = gw.new_scene(Lother); + gw.set_color(sc2,leda_blue); + + construct_pointset CP; + geo_scene sc3 = gw.new_scene(CP, sc1, leda_string("2d point set")); + gw.set_color(sc3,leda_blue); + + nearest_neighbors NN; + geo_scene sc4 = gw.new_scene(NN, sc2, leda_string("k nearest neighbors")); + gw.set_fill_color(sc4,leda_red); + gw.set_color(sc4,leda_red); + gw.set_point_style(sc4,leda_circle_point); + gw.set_line_width(sc4,4); + + mst MS; + geo_scene sc5 = gw.new_scene(MS, sc1, leda_string("Minimum spanning tree")); + gw.set_line_width(sc5,2); + + gw.set_all_visible(true); + gw.add_dependence(sc1,sc4); + + gw.edit(sc1); + + return 0; +} +\end{verbatim} + + +\ccHtmlLinksOn + +\subsection{Using the LEDA kernel} + +We provide also traits classes for the \leda\ floating point and rational kernels. The next short +example demonstrates the usage of the two dimensional point set with the rational \leda\ kernel. + +\ccHtmlLinksOff + +\begin{verbatim} +#include +#include +#include +#include + + +typedef CGAL::point_set_leda_rat_traits_2 TRAITS; +typedef CGAL::Point_set_2::Edge Edge; +typedef CGAL::Point_set_2::Vertex Vertex; + +void output(leda_window& W, const CGAL::Point_set_2& PSR_rat) +{ + W.clear(); + leda_edge e; + forall_edges(e,PSR_rat) W << leda_segment(PSR_rat.seg(e).to_segment()); +} + +int main() +{ + int i; + CGAL::Point_set_2 PSR_rat; + leda_window W(500,400); + W.init(-500,500,-400); + W.display(); + + // insert operation + for (i=0; i<30; i++) { + leda_rat_point pnew; + W >> pnew; + PSR_rat.insert(pnew); + output(W,PSR_rat); + } + + // delete operation + for (i=0; i<3; i++) { + leda_rat_point pnew; + W >> pnew; + Vertex v = PSR_rat.nearest_neighbor(pnew); + PSR_rat.del(v); + output(W,PSR_rat); + } + + W.set_point_style(leda_disc_point); + + leda_rat_circle rc; + W >> rc; W << rc; + + leda_list LV; + + // circular range search + PSR_rat.range_search(rc, std::back_inserter(LV)); + Vertex v; + W.set_color(leda_red); + forall(v,LV) W << PSR_rat.pos(v); + + leda_rat_point pt1,pt2,pt3,pt4; + W >> pt1; W << pt1; + W >> pt2; W << pt2; + W >> pt3; W << pt3; + + LV.clear(); + + // triangular range search + PSR_rat.range_search(pt1,pt2,pt3,std::back_inserter(LV)); + leda_list::iterator it; + W.set_color(leda_green); + + for (it=LV.begin();it != LV.end(); it++) + W << PSR_rat.pos(*it); + + LV.clear(); + + W >> pt1; W << pt1; + W >> pt3; W << pt3; + + pt2 = leda_rat_point(pt3.xcoord(),pt1.ycoord()); + pt4 = leda_rat_point(pt1.xcoord(),pt3.ycoord()); + + W.set_color(leda_orange); + + // iso rectangular range search + PSR_rat.range_search(pt1,pt2,pt3,pt4,std::back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + W << PSR_rat.pos(*it); + + W.read_mouse(); + return 1; +} +\end{verbatim} + +\ccHtmlLinksOn diff --git a/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/Point_set_2.tex b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/Point_set_2.tex new file mode 100644 index 00000000000..2a7bb5316be --- /dev/null +++ b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/Point_set_2.tex @@ -0,0 +1,290 @@ +% +----------------------------------------------------------+ +%--------------------------------------------- +% Point_set_2 data type +%--------------------------------------------- +\begin{ccRefClass}{Point_set_2} + +\ccDefinition + +\ccInclude{CGAL/Point_set_2.h} + +An instance $T$ of data type \ccRefName\ is a planar embedded bidirected +graph representing the {\em Delaunay Triangulation} of its vertex set. +The position of a vertex $v$ is given by $T.pos(v)$ and we use +$S = \{ T.pos(v) \mid v \in T \}$ to denote the underlying point set. +Each face of $T$ (except for the outer face) is a triangle whose +circumscribing circle does not contain any point of $S$ in its interior. +For every edge $e$, the sequence +\[e, T.face\_cycle\_succ(e), T.face\_cycle\_succ(T.face\_cycle\_succ(e)),\ldots\] +traces the boundary of the face to the left of $e$. +The edges of the outer face of $T$ form the convex hull of $S$; the trace of +the convex hull is clockwise. +The subgraph obtained from $T$ by removing all diagonals of +co-circular quadrilaterals is called the {\em Delaunay Diagram} +of $S$. + +The class \ccRefName\ provides operations for inserting and deleting points, +point location, nearest neighbor searches, and navigation in both +the triangulation and the diagram. + +Note that the \ccRefName\ is derived from the \leda\ GRAPH class +(Parameterized Graphs). That means that it provides all constant +graph operations (like $reversal$, $all\_edges$, ...). +See the \leda\ user manual or \leda\ book ~\cite{LEDAbook} for more details. + +Be aware that the nearest neighbor queries for a point (not for a node) and +the range search queries for circles, triangles, and rectangles are non-const +operations and modify the underlying graph. The set of nodes and edges is +not changed; however, it is not guaranteed that the underlying Delaunay +triangulation is unchanged. + +The \ccRefName\ class of \cgal\ depends on a template parameter standing for a +geometric traits class. This traits class has to provide the geometric objects needed +in \ccRefName\ and geometric predicates on these objects. +\ccCreationVariable{T} + + +\ccHtmlLinksOff + + +\ccTypes +\ccThree{typedef Traits::Point Point;}{the point type}{} +\ccThreeToTwo +\ccTypedef{typedef Traits::Point Point;}{the point type}{} +\ccTypedef{typedef Traits::Segment Segment;}{the segment type} +\ccTypedef{typedef Traits::Circle Circle;}{the circle type} +\ccTypedef{typedef Traits::Line Line;}{the line type} +\ccTypedef{typedef Traits::FT Numb_type;}{the field type of the representation class} +\ccNestedType{Vertex}{the vertex type.} +\ccNestedType{Edge}{the edge type.} + + +\ccHtmlLinksOn + + +\ccCreation + +\ccConstructor{Point_set_2();} +{creates an empty \ccRefName\ .} + +\ccConstructor{Point_set_2(const std::list& S);} +{creates a \ccRefName\ \ccVar\ of the points in $S$. +If $S$ contains multiple occurrences of points only the last +occurrence of each point is retained.} + +\ccConstructor{template +Point_set_2d(InputIterator first, InputIterator last);} +{creates a \ccRefName\ \ccVar\ of the points in the range +[$first$,$last$).} + + +\ccOperations + +\ccMethod{void init(const std::list& L);} +{ makes \ccVar\ a \ccRefName\ for the points in $L$.} + +\ccMethod{template +void init(InputIterator first, InputIterator last);} +{ makes \ccVar\ a \ccRefName\ for the points in the range +[$first$,$last$).} + +\ccMethod{template +OutputIterator points(OutputIterator out);} +{ places all points of \ccVar as a sequence of objects of type +$Point$ in a container of value type of $out$, +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence.} + +\ccMethod{template +OutputIterator segments(OutputIterator out);} +{ places all segments of \ccVar\ as a sequence of objects of type +$Segment$ in a container of value type of $out$, +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence.} + +\ccHtmlLinksOff + +\ccMethod{template +OutputIterator vertices(OutputIterator out);} +{ places all vertices of \ccVar\ as a sequence of objects of type +Vertex in a container of value type of $out$, +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence.} + +\ccHtmlLinksOn + + +\ccMethod{template +OutputIterator edges(OutputIterator out);} +{ places all points of \ccVar\ as a sequence of objects of type +$Edge$ in a container of value type of $out$, +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence.} + +\ccMethod{Edge d_face_cycle_succ(Edge e);} +{ returns the face cycle successor of $e$ in the Delaunay diagram +of \ccVar . \ccPrecond $e$ belongs to the Delaunay diagram.} + +\ccMethod{Edge d_face_cycle_pred(Edge e);} +{ returns the face cycle predecessor of $e$ in the Delaunay diagram +of \ccVar. \ccPrecond $e$ belongs to the Delaunay diagram.} + +\ccMethod{bool is_empty();} +{ decides whether \ccVar\ is empty. } + +\ccMethod{void clear();} +{ makes \ccVar\ empty. } + +\ccMethod{Edge locate(Point p);} +{ returns an edge $e$ of \ccVar\ that contains $p$ or that +borders the face that contains $p$. In the former case, +a hull edge is returned if $p$ lies on the boundary of the convex hull. +In the latter case we have $T.orientation(e,p) > 0$ except if all points of +$T$ are collinear and +$p$ lies on the induced line. In this case $target(e)$ is visible from +$p$. The function returns $NULL$ if $T$ has no edge.} + + +\ccHtmlLinksOff + +\ccMethod{Vertex lookup(Point p);} +{ if \ccVar\ contains a Vertex $v$ with $|pos(v)| = p$ +the result is $v$ otherwise the result is $NULL$. } + +\ccMethod{Vertex insert(Point p);} +{ inserts point $p$ into \ccVar\ and returns the corresponding vertex. +More precisely, if there is already a vertex $v$ in \ccVar\ positioned +at $p$ then $pos(v)$ is made identical to $p$ and if there is no +such node then a new node $v$ with $pos(v) = p$ is added to $T$. +In either case, $v$ is returned.} + +\ccMethod{void del(Vertex v);} +{ removes the vertex $v$ from \ccVar. \ccPrecond v is a vertex in \ccVar.} + +\ccMethod{void del(Point p);} +{ removes the vertex $v$ with position $p$ from \ccVar. If there is +no such vertex in \ccVar, the function returns without changing \ccVar. } + +\ccMethod{Vertex nearest_neighbor(Point p);} +{ computes a vertex $v$ of \ccVar\ that is closest to $p$. +If \ccVar\ is empty, $NULL$ is returned. +This is a non-const operation.} + +\ccMethod{Vertex nearest_neighbor(Vertex v);} +{ computes a vertex $w$ of \ccVar\ that is closest to $v$. +If $v$ is the only vertex in \ccVar\ , $NULL$ is returned. +\ccPrecond $v$ is a vertex in \ccVar.} + +\ccMethod{template +OutputIterator nearest_neighbors(Point p, int k, OutputIterator res);} +{ computes the $k$ nearest neighbors of $p$, and places them as a sequence of objects of type +Vertex in a container of value type of $res$ +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence. } + +\ccMethod{template +OutputIterator nearest_neighbors(Vertex v, int k,OutputIterator res);} +{ computes the $k$ nearest neighbors of $v$, and places them as a sequence of objects of type +Vertex in a container of value type of $res$ +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence. } + +\ccMethod{template +OutputIterator range_search(const Circle& C, OutputIterator res);} +{ computes all vertices contained in the closure of disk $C$. +\ccPrecond $C$ must be a proper circle (not a straight line). +The computed vertices will be placed as a sequence of objects in a container of value type +of $res$ +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence. +This is a non-const operation.} + +\ccMethod{template +OutputIterator range_search(const Point& a, const Point& b, const Point& c,OutputIterator res);} +{ computes all vertices contained in the closure of the triangle $(a,b,c)$.\\ +\ccPrecond $a$, $b$, and $c$ must not be collinear. +The computed vertices will be placed as a sequence of objects in a container of value type +of $res$ +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence. +This is a non-const operation.} + +\ccMethod{template +OutputIterator range_search(const Point& a1, const Point& b1, const Point& c1,const Point& +d1,OutputIterator res);} +{ computes all vertices contained in the closure of the iso-rectangle $(a1,b1,c1,d1)$.\\ +\ccPrecond $a1$ is the lower left point, $b1$ the lower right, $c1$ the upper +right and $d1$ the upper left point of the iso rectangle. +The computed vertices will be placed as a sequence of objects in a container of value type +of $res$ +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence. +This is a non-const operation.} + +\ccMethod{template +OutputIterator minimum_spanning_tree(OutputIterator result);} +{ places all edges of the minimum spanning tree of \ccVar\ as a sequence of objects of type +$Edge$ in a container of type corresponding to the type of $out$ +which points to the first object in the sequence. The function +returns an output iterator pointing to the position beyond the end +of the sequence.} + +\ccMethod{bool is_non_diagram_edge(Edge e);} +{ checks whether $e$ is a non-diagram edge. } + +\ccMethod{Point pos(Vertex v);} +{ returns the position of $v$ in \ccVar.} + +\ccMethod{Vertex source(Edge e);} +{ returns the source vertex of $e$.} + +\ccMethod{Vertex target(Edge e);} +{ returns the target vertex of $e$.} + +\ccMethod{Point pos_source(Edge e);} +{ returns the position of the source of $e$ in \ccVar.} + +\ccMethod{Point pos_target(Edge e);} +{ returns the position of the target of $e$ in \ccVar.} + +\ccMethod{Segment seg(Edge e);} +{ returns the line segment corresponding to edge $e$ starting +at $pos\_source(e)$.} + +\ccMethod{Line supporting_line(Edge e);} +{ returns the supporting line of edge $e$.} + +\ccMethod{int orientation(Edge e, Point p);} +{ returns $orientation(T.pos\_source(e),T.pos\_target(e),p)$.} + +\ccMethod{Edge get_hull_edge();} +{ returns an edge of the outer face of \ccVar\ (i.e., an edge of the convex hull). } + +\ccMethod{bool is_diagram_edge(Edge e);} +{returns true if $e$ is an edge of the Delaunay diagram, i.e., either +an edge on the convex hull or an edge where the incident triangles have +distinct circumcircles.} + +\ccMethod{bool is_hull_edge(Edge e);} +{returns true if $e$ is an edge of the convex hull of \ccVar, i.e., +an edge on the face cycle of the outer face. } + +\ccHtmlLinksOn + +\ccMethod{int dim();} +{returns $-1$ if \ccVar\ is empty, returns $0$ if \ccVar +consists of only one point, +returns $1$ if \ccVar\ consists of at least two points +and all points in \ccVar\ +are collinear, and returns $2$ otherwise.} + +\end{ccRefClass} diff --git a/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/Point_set_traits.tex b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/Point_set_traits.tex new file mode 100644 index 00000000000..093a1593924 --- /dev/null +++ b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/Point_set_traits.tex @@ -0,0 +1,114 @@ +\begin{ccRefConcept} {Point_set_traits} + +\subsection{Requirements for the Point\_set traits class} + +A point set traits class has to provide some primitives that are used by the point set class. +The following catalog lists the involved primitives. +The types used in the traits class must have a copy constructor and an assignment operator. + +\ccCreationVariable{ps_traits} +\ccTypes + +\ccNestedType{FT}% + {The field type of the representation class of the point, segment, circle and line types.} + +\ccNestedType{Point}% + {The point type on which the point set operates.} + +\ccNestedType{Circle}% + {The circle type on which the point set operates.} + + +\ccHtmlLinksOff + +\ccNestedType{Line}% + {The line type on which the point set operates.} + +\ccHtmlLinksOn + +\ccNestedType{Segment}% + {The segment type on which the point set operates.} + +\ccNestedType{Compare_xy_2}% + {The primitive must provide + \ccc{int operator()(const Point& p1,const Point& p2) const} + and has to be derived from $leda\_cmp\_base$. + The operator has to compare the points $p1$ and $p2$ lexicographically in + $xy$ order. If $p1$ is smaller, the operator has to return -1, if $p1$ + is larger, the operator has to return 1, 0 otherwise. + } + +\ccNestedType{Compare_dist_2}% + {The primitive must provide + \ccc{Comparison_result operator()(const Point& p1,const Point& p2, const Point& p3) const}. + The operator has to compare the distances of points $p2$ and $p3$ to $p1$. + The operator returns \ccc{SMALLER}, if $p2$ is closer (to $p1$), \ccc{LARGER} if $p3$ is closer, + \ccc{EQUAL} otherwise. + } + + \ccNestedType{Orientation}% + {The primitive must provide + \ccc{Orientation operator()(const Point& p1,const Point& p2,const Point& p3) const}. + This operator has to return \ccc{COLLINEAR} if the 3 points are collinear, + \ccc{LEFTTURN} if $p3$ lies on the left of the directed line through $p1$ and $p2$, + \ccc{RIGHTTURN} otherwise. + } + + \ccNestedType{Side_of_oriented_circle_2}% + {The primitive must provide + \ccc{Oriented_side operator()(const Point& p1,const Point& p2,const Point& p3, const Point& p4) const}. + This operator has to return \ccc{ON_POSITIVE_SIDE} if $p4$ lies on the positive side of the circle through + the points $p1$,$p2$ and $p3$, \ccc{ON_NEGATIVE_SIDE} if $p4$ lies on the negative side of the circle, + \ccc{ON_ORIENTED_BOUNDARY} otherwise. + } + + \ccNestedType{Side_of_halfspace_2}% + {The primitive must provide + \ccc{Orientation operator()(const Point& a,const Point& b, const Point& p3) const }. + This operator has to return \ccc{LEFTTURN} if $p3$ lies in the open halfspace $h$ orthogonal to vector + $b-a$ containing $b$ and having $a$ on its boundary, \ccc{COLLINEAR} if $p3$ is on the boundary of $h$ and + \ccc{RIGHTTURN} otherwise. + } + + \ccNestedType{Segment_has_on_2}% + {The primitive must provide + \ccc{bool operator()(const Segment& seg, const Point& p) const }. + This operator has to return true if $seg$ contains $p$, false otherwise.} + + \ccNestedType{Squared_distance}% + {The primitive must provide + \ccc{FT operator()(const Point& p1,const Point& p2) const}. + The operator has to return the squared distance from $p1$ to $p2$.} + + \ccNestedType{Squared_distance_to_line}% + {The primitive must provide + \ccc{FT operator()(const Line& l,const Point& p) const}. + The operator has to return the squared distance from $l$ to $p$.} + + \ccNestedType{Circle_bounded_side_2}% + {The primitive must provide + \ccc{Bounded_side operator()(const Circle& c, const Point& p) const}. + The operator has to return \ccc{ON_BOUNDED_SIDE} if $p$ lies on the bounded side of $c$, + \ccc{ON_UNBOUNDED_SIDE} if $p$ lies on the unbounded side of $c$, \ccc{ON_BOUNDARY} otherwise.} + + \ccNestedType{Circle_center_2}% + {The primitive must provide + \ccc{Point operator()(const Circle& c) const}. + The operator has to return the center of $c$.} + + \ccNestedType{Construct_circle_2}% + {This primitive constructs a circle. It must provide + \ccc{Circle operator()(const Point& p1,const Point& p2, const Point& p3) const }. + The points $p1$, $p2$ and $p3$ are on the boundary.} + + \ccNestedType{Construct_segment_2}% + {This primitive constructs a segment. It must provide + \ccc{Segment operator()(const Point& p1,const Point& p2) const}. + Point $p1$ is the source of the segment, $p2$ the target.} + + \ccNestedType{Construct_line_2}% + {This primitive constructs a line. It must provide + \ccc{Line operator()(const Point& p1,const Point& p2) const}. + The line is constructed through $p1$ and $p2$.} + +\end{ccRefConcept} diff --git a/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/cgal.bib b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/cgal.bib new file mode 100644 index 00000000000..491f08aa94b --- /dev/null +++ b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/cgal.bib @@ -0,0 +1,17 @@ +@Book{LEDAbook, + author + = + "K. Mehlhorn and S. N\"aher", + title + = + "LEDA -- A platform for combnatorial and geometric computing", + publisher + = + "Cambridge University Press", + + year + = + "1999", + +} + diff --git a/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/intro.tex b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/intro.tex new file mode 100644 index 00000000000..f15c2250bd0 --- /dev/null +++ b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/intro.tex @@ -0,0 +1,26 @@ +% +------------------------------------------------------------------------+ +% | CGAL Reference Manual: Point_set_2.tex +% +------------------------------------------------------------------------+ + + +\ccParDims + +\clearpage +\section{Reference pages for Point Set in 2D} + +\section*{Summary} + +The two dimensional point set is a class for geometric queries. +It supports circular, triangular and iso rectangular range searches, +nearest neighbor searches and the computation of the minimum spanning tree. +The point set is a dynamic data structure supporting the insertion and +deletion of points. + +\subsection*{Concepts} +\ccc{Point_set_traits}\\ + +\subsection*{Classes} +\ccc{CGAL::Point_set_2}\\ +\ccc{CGAL::point_set_traits_2}\\ +\ccc{CGAL::point_set_leda_float_traits_2}\\ +\ccc{CGAL::point_set_leda_rat_traits_2}\\ diff --git a/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/main.tex b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/main.tex new file mode 100644 index 00000000000..32d2b0163f0 --- /dev/null +++ b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/main.tex @@ -0,0 +1,15 @@ +% +------------------------------------------------------------------------+ +% | CGAL Reference Manual: main.tex +% +------------------------------------------------------------------------+ +% | Point_set_2 +% | +% +------------------------------------------------------------------------+ + +\input{Point_set_2_ref/intro} +\input{Point_set_2_ref/Point_set_2} +\input{Point_set_2_ref/Point_set_traits} +\input{Point_set_2_ref/point_set_traits_2} +\input{Point_set_2_ref/point_set_leda_float_traits_2} +\input{Point_set_2_ref/point_set_leda_rat_traits_2} + +%% EOF %% diff --git a/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/point_set_leda_float_traits_2.tex b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/point_set_leda_float_traits_2.tex new file mode 100644 index 00000000000..c6ffd76d533 --- /dev/null +++ b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/point_set_leda_float_traits_2.tex @@ -0,0 +1,35 @@ +\begin{ccRefClass}{point_set_leda_float_traits_2} +\subsubsection{Traits classes for \leda\ 2D Points} + +\ccInclude{CGAL/point_set_leda_traits_2.h} + +The traits class \ccc{point_set_leda_float_traits_2} deals with \leda\ 2D float kernel objects. + +\ccTypes +\ccThree{typedef ttttttttttttttttttttt}{tttttttttt}{} +\ccThreeToTwo +\ccTypedef{typedef double FT;}{} +\ccTypedef{typedef leda_point Point;}{} +\ccTypedef{typedef leda_segment Segment;}{} + +\ccHtmlLinksOff + +\ccTypedef{typedef leda_line Line;}{} + +\ccHtmlLinksOn + +\ccTypedef{typedef leda_circle Circle;}{} +\ccNestedType{Compare_xy_2}{} +\ccNestedType{Compare_dist_2}{} +\ccNestedType{Orientation}{} +\ccNestedType{Side_of_oriented_circle_2}{} +\ccNestedType{Side_of_halfspace_2}{} +\ccNestedType{Segment_has_on_2}{} +\ccNestedType{Squared_distance}{} +\ccNestedType{Squared_distance_to_line}{} +\ccNestedType{Circle_bounded_side_2}{} +\ccNestedType{Circle_center_2}{} +\ccNestedType{Construct_circle_2}{} +\ccNestedType{Construct_segment_2}{} +\ccNestedType{Construct_line_2}{} +\end{ccRefClass} diff --git a/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/point_set_leda_rat_traits_2.tex b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/point_set_leda_rat_traits_2.tex new file mode 100644 index 00000000000..09c4cbccfec --- /dev/null +++ b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/point_set_leda_rat_traits_2.tex @@ -0,0 +1,35 @@ +\begin{ccRefClass}{point_set_leda_rat_traits_2} + +The traits class \ccc{point_set_leda_rat_traits_2} deals with \leda\ 2D rational kernel objects. + +\ccTypes +\ccThree{typedef ttttttttttttttttttttttt}{tttttttttt}{} +\ccThreeToTwo +\ccTypedef{typedef leda_rational FT;}{} +\ccTypedef{typedef leda_rat_point Point;}{} +\ccTypedef{typedef leda_rat_segment Segment;}{} + +\ccHtmlLinksOff + +\ccTypedef{typedef leda_rat_line Line;}{} + +\ccHtmlLinksOn + +\ccTypedef{typedef leda_rat_circle Circle;}{} +\ccNestedType{Compare_xy_2}{} +\ccNestedType{Compare_dist_2}{} +\ccNestedType{Orientation}{} +\ccNestedType{Side_of_oriented_circle_2}{} +\ccNestedType{Side_of_halfspace_2}{} +\ccNestedType{Segment_has_on_2}{} +\ccNestedType{Squared_distance}{} +\ccNestedType{Squared_distance_to_line}{} +\ccNestedType{Circle_bounded_side_2}{} +\ccNestedType{Circle_center_2}{} +\ccNestedType{Construct_circle_2}{} +\ccNestedType{Construct_segment_2}{} +\ccNestedType{Construct_line_2}{} +\end{ccRefClass} + + +\ccParDims diff --git a/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/point_set_traits_2.tex b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/point_set_traits_2.tex new file mode 100644 index 00000000000..5003383739c --- /dev/null +++ b/Packages/Point_set_2/doc_tex/basic/Point_set_2/Point_set_2_ref/point_set_traits_2.tex @@ -0,0 +1,36 @@ +\begin{ccRefClass}{point_set_traits_2} +\subsubsection{Traits class for \cgal\ 2D kernel objects} + +\ccInclude{CGAL/point_set_traits_2.h} + +The traits class \ccRefName\ deals with \cgal\ 2D kernel objects. + +\ccTypes +\ccThree{typedef ttttttttttttttttttttt}{tttttttttt}{} +\ccThreeToTwo +\ccTypedef{typedef T::FT FT;}{} +\ccTypedef{typedef Point_2 Point;}{} +\ccTypedef{typedef Segment_2 Segment;}{} + +\ccHtmlLinksOff + +\ccTypedef{typedef Line_2 Line;}{} + +\ccHtmlLinksOn + +\ccTypedef{typedef Circle_2 Circle;}{} +\ccNestedType{Compare_xy_2}{} +\ccNestedType{Compare_dist_2}{} +\ccNestedType{Orientation}{} +\ccNestedType{Side_of_oriented_circle_2}{} +\ccNestedType{Side_of_halfspace_2}{} +\ccNestedType{Segment_has_on_2}{} +\ccNestedType{Squared_distance}{} +\ccNestedType{Squared_distance_to_line}{} +\ccNestedType{Circle_bounded_side_2}{} +\ccNestedType{Circle_center_2}{} +\ccNestedType{Construct_circle_2}{} +\ccNestedType{Construct_segment_2}{} +\ccNestedType{Construct_line_2}{} + +\end{ccRefClass} diff --git a/Packages/Point_set_2/doc_tex/basic/Point_set_2/cgal.bib b/Packages/Point_set_2/doc_tex/basic/Point_set_2/cgal.bib new file mode 100644 index 00000000000..491f08aa94b --- /dev/null +++ b/Packages/Point_set_2/doc_tex/basic/Point_set_2/cgal.bib @@ -0,0 +1,17 @@ +@Book{LEDAbook, + author + = + "K. Mehlhorn and S. N\"aher", + title + = + "LEDA -- A platform for combnatorial and geometric computing", + publisher + = + "Cambridge University Press", + + year + = + "1999", + +} + diff --git a/Packages/Point_set_2/doc_tex/basic/Point_set_2/main.tex b/Packages/Point_set_2/doc_tex/basic/Point_set_2/main.tex new file mode 100644 index 00000000000..840d0ed0968 --- /dev/null +++ b/Packages/Point_set_2/doc_tex/basic/Point_set_2/main.tex @@ -0,0 +1,12 @@ +% +------------------------------------------------------------------------+ +% | CGAL Reference Manual: main.tex +% +------------------------------------------------------------------------+ +% | Point_set_2 +% | +% | 15.10.1999 Matthias Baesken +% +------------------------------------------------------------------------+ + +\input{Point_set_2} +\input{Point_set_2_ref/main} + +%% EOF %% diff --git a/Packages/Point_set_2/examples/Point_set_2/makefile b/Packages/Point_set_2/examples/Point_set_2/makefile new file mode 100644 index 00000000000..94440046acb --- /dev/null +++ b/Packages/Point_set_2/examples/Point_set_2/makefile @@ -0,0 +1,48 @@ +include $(CGAL_MAKEFILE) + +#---------------------------------------------------------------------# +# compiler flags +#---------------------------------------------------------------------# + +CXXFLAGS = \ + $(CGAL_CXXFLAGS) + + + +#---------------------------------------------------------------------# +# linker flags +#---------------------------------------------------------------------# + +LIBPATH = \ + $(TESTSUITE_LIBPATH) \ + $(CGAL_LIBPATH) + +LDFLAGS = \ + $(TESTSUITE_LDFLAGS) \ + $(CGAL_LDFLAGS) + + +#---------------------------------------------------------------------# +# target entries +#---------------------------------------------------------------------# + +all: \ + range_search \ + nearest_nb1 + +range_search$(EXE_EXT) : range_search$(OBJ_EXT) + $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)range_search range_search$(OBJ_EXT) $(LDFLAGS) + +nearest_nb1$(EXE_EXT) : nearest_nb1$(OBJ_EXT) + $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)nearest_nb1 nearest_nb1$(OBJ_EXT) $(LDFLAGS) + +clean: + rm -f range_search nearest_nb1 rs_test *.o *.obj *.exe core + +#---------------------------------------------------------------------# +# suffix rules +#---------------------------------------------------------------------# + +.C$(OBJ_EXT): + $(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $< + diff --git a/Packages/Point_set_2/examples/Point_set_2/nearest_nb1.C b/Packages/Point_set_2/examples/Point_set_2/nearest_nb1.C new file mode 100644 index 00000000000..30f31fef3e1 --- /dev/null +++ b/Packages/Point_set_2/examples/Point_set_2/nearest_nb1.C @@ -0,0 +1,121 @@ +// ============================================================================ +// +// Copyright (c) 1999 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------------- +// release : +// release_date : +// +// file : examples/Point_set_2/nearest_nb1.C +// revision : 1.2.4 +// revision_date : 14 September 2000 +// author(s) : Kurt Mehlhorn, Stefan Naeher, Matthias Baesken +// +// coordinator : Matthias Baesken, Halle () +// ============================================================================ + + +#include + +#if !defined(CGAL_USE_LEDA) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + + +#include + +#include +#include + +#include +#include + +using namespace CGAL; +using namespace std; + +typedef Cartesian REP; +typedef point_set_traits_2 TRAITS; +typedef Point_set_2::Edge Edge; +typedef Point_set_2::Vertex Vertex; + +Point_set_2 PSet; + +Point_2 ar1[5]; + +int check1(std::list L) +{ + cout << "check 1!\n"; + if (L.size() != 5) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar1[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int main() +{ + std::list > Lr; + + int w1,w2; + + Point_2 p1(12,14,1); + Point_2 p2(-12,14,1); + Point_2 p3(2,11,1); + Point_2 p4(5,6,1); + Point_2 p5(67,38,10); + Point_2 p6(11,20,1); + Point_2 p7(-5,6,1); + Point_2 p8(12,0,1); + Point_2 p9(4,31,1); + Point_2 p10(-10,-10,1); + + Lr.push_back(p1); Lr.push_back(p2); Lr.push_back(p3); + Lr.push_back(p4); Lr.push_back(p5); Lr.push_back(p6); + Lr.push_back(p7); Lr.push_back(p8); Lr.push_back(p9); + Lr.push_back(p10); + + PSet.init(Lr.begin(),Lr.end()); + + // init + ar1[0]=p4; ar1[1]=p5; ar1[2]=p3; ar1[3]=p7; ar1[4]=p8; + + Point_2 actual(30,45,10); + + // nearest neighbor ... + Vertex v = PSet.nearest_neighbor(actual); + cout << "Nearest neighbor:" << PSet.pos(v) << "\n"; + + if (PSet.pos(v) == p4) w1=0; else w1=1; + + // k nearest neighbors ... + std::list L; + std::list::const_iterator it; + + PSet.nearest_neighbors(actual,5,back_inserter(L)); + cout << "actual point: " << actual << "\n"; + + for (it=L.begin();it != L.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w2=check1(L); + + if (w1==0 && w2==0) return 0; + else return 1; +} + +#endif diff --git a/Packages/Point_set_2/examples/Point_set_2/range_search.C b/Packages/Point_set_2/examples/Point_set_2/range_search.C new file mode 100644 index 00000000000..388412ec69f --- /dev/null +++ b/Packages/Point_set_2/examples/Point_set_2/range_search.C @@ -0,0 +1,175 @@ +// ============================================================================ +// +// Copyright (c) 1999 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------------- +// release : +// release_date : +// +// file : examples/Point_set_2/range_search.C +// revision : 1.2.4 +// revision_date : 14 September 1999 +// author(s) : Kurt Mehlhorn, Stefan Naeher, Matthias Baesken +// +// coordinator : Matthias Baesken, Halle () +// ============================================================================ + +#include + +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 400) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + + +#include + +#include +#include + +#include +#include + +using namespace CGAL; +using namespace std; + +typedef Cartesian REP; +typedef point_set_traits_2 TRAITS; +typedef Point_set_2::Edge Edge; +typedef Point_set_2::Vertex Vertex; + +Point_set_2 PSet; + +Point_2 ar1[6]; +Point_2 ar2[3]; +Point_2 ar3[3]; + +int check1(std::list L) +{ + cout << "check 1!\n"; + if (L.size() != 6) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar1[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int check2(std::list L) +{ + cout << "check 2!\n"; + if (L.size() != 3) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar2[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int check3(std::list L) +{ + cout << "check 3!\n"; + if (L.size() != 3) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar3[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int main() +{ + Point_2 pnew(120,62,10); + + int w1,w2,w3; + + std::list > Lr; + + Point_2 p1(12,14,1); + Point_2 p2(-12,14,1); + Point_2 p3(2,11,1); + Point_2 p4(5,6,1); + Point_2 p5(67,38,10); + Point_2 p6(11,20,1); + Point_2 p7(-5,6,1); + Point_2 p8(12,0,1); + Point_2 p9(4,31,1); + Point_2 p10(-10,-10,1); + + // init + ar1[0]=p1; ar1[1]=p6; ar1[2]=p3; ar1[3]=p4; ar1[4]=p5; ar1[5]=pnew; + ar2[0]=p2; ar2[1]=p3; ar2[2]=p1; + ar3[0]=p7; ar3[1]=p10; ar3[2]=p3; + + Lr.push_back(p1); Lr.push_back(p2); Lr.push_back(p3); + Lr.push_back(p4); Lr.push_back(p5); Lr.push_back(p6); + Lr.push_back(p7); Lr.push_back(p8); Lr.push_back(p9); + Lr.push_back(p10); + + PSet.init(Lr.begin(),Lr.end()); + + cout << "insert!\n"; cout.flush(); + PSet.insert(pnew); + + + cout << "range search for circle !\n"; + Circle_2 rc(p5,p6); + + std::list LV; + PSet.range_search(rc,back_inserter(LV)); + + std::list::const_iterator it; + for (it=LV.begin();it != LV.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w1 = check1(LV); + + cout << "range search for triangle !\n"; + + LV.clear(); + PSet.range_search(p1,p2,p3,back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w2 = check2(LV); + LV.clear(); + + cout << "range search for iso rectangle !\n"; + Point_2 pt1=p10; // lower left + Point_2 pt3=p3; // upper right + + Point_2 pt2 = Point_2(pt3.x(),pt1.y()); + Point_2 pt4 = Point_2(pt1.x(),pt3.y()); + + PSet.range_search(pt1,pt2,pt3,pt4,back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w3 = check3(LV); + + if (w1==0 && w2==0 && w3==0) return 0; + else return 1; +} + +#endif diff --git a/Packages/Point_set_2/include/CGAL/Point_set_2.h b/Packages/Point_set_2/include/CGAL/Point_set_2.h new file mode 100644 index 00000000000..e15b0d2db3c --- /dev/null +++ b/Packages/Point_set_2/include/CGAL/Point_set_2.h @@ -0,0 +1,1870 @@ +// ====================================================================== +// +// Copyright (c) 1999 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------- +// +// release : +// release_date : 2000, September 14 +// +// file : include/CGAL/Point_set_2.h +// package : Point_set_2 (1.2.4) +// maintainer : Matthias Baesken +// revision : 1.2.4 +// revision_date : 14 September 2000 +// author(s) : Kurt Mehlhorn, Stefan Naeher, Matthias Baesken +// +// coordinator : Matthias Baesken, Halle () +// ====================================================================== + +#ifndef CGAL_POINT_SET_2_H +#define CGAL_POINT_SET_2_H + +#if !defined(LEDA_ROOT_INCL_ID) +#define LEDA_ROOT_INCL_ID 400900 +#include +#endif + +#if !defined(LEDA_STL_ITERATORS) +#define LEDA_STL_ITERATORS +#endif + + +#ifndef POINT_SET_LEDA_ONLY +#include +#endif + +#ifdef POINT_SET_LEDA_ONLY +# define CGAL_BEGIN_NAMESPACE namespace CGAL { +# define CGAL_END_NAMESPACE } +#endif + +#include +#include + +#ifndef POINT_SET_LEDA_ONLY + +#if (__MSC_VER > 1100) +#if defined(__ALL_MEMBERS_INSTANT__) +#undef __ALL_MEMBERS_INSTANT__ +#endif +#endif + +#endif + +#include +#include + +enum cgal_ps_delaunay_edge_info{ CGAL_DIAGRAM_EDGE = 0, CGAL_DIAGRAM_DART = 0, + CGAL_NON_DIAGRAM_EDGE = 1, CGAL_NON_DIAGRAM_DART = 1, + CGAL_HULL_EDGE = 2, CGAL_HULL_DART = 2 + }; + + +#include + +// Traits classes for the 2d point set + +#if defined(LEDA_PREFIX) +#include +#endif + +#include + +#if defined(LEDA_PREFIX) +#include +#endif + + +#include + +#if defined(LEDA_PREFIX) +#include +#endif + + +// from graph_alg.h +extern leda_list MIN_SPANNING_TREE(const leda_graph&,int(*cmp)(const leda_edge&,const leda_edge&)); + + +CGAL_BEGIN_NAMESPACE + + +template +class __exportC Point_set_2 : public GRAPH<__typename TR::Point,int> +{ + +public: + typedef typename TR::FT Numb_type; + typedef typename TR::Point Point; + typedef typename TR::Circle Circle; + typedef typename TR::Segment Segment; + typedef typename TR::Line Line; + + typedef leda_edge Edge; + typedef leda_node Vertex; + + //functionality on these types... + typedef typename TR::Compare_xy_2 Comparepoints; + typedef typename TR::Compare_dist_2 Comparedist; + typedef typename TR::Orientation Orientation_2; + typedef typename TR::Side_of_oriented_circle_2 Sideofcircle; + typedef typename TR::Side_of_halfspace_2 Sideofhalfspace; + typedef typename TR::Segment_has_on_2 Segmentcontains; + typedef typename TR::Squared_distance Sqrdist; + typedef typename TR::Squared_distance_to_line Linesqrdist; + typedef typename TR::Circle_bounded_side_2 Circleptori; + typedef typename TR::Circle_center_2 Circlecenter; + + //constructors... + typedef typename TR::Construct_circle_2 Createcircle_3p; + typedef typename TR::Construct_segment_2 Createsegment_2p; + typedef typename TR::Construct_line_2 Createline_2p; + + +private: + TR traits; + + Comparepoints tr_comparepoints; + Comparedist tr_comparedist; + Orientation_2 tr_orientation; + Sideofcircle tr_so_circle; + Sideofhalfspace tr_so_hp; + Segmentcontains tr_seg_contains; + Sqrdist tr_sqrdist; + Linesqrdist tr_linesqrdist; + Circleptori tr_circleptori; + Circlecenter tr_circlecenter; + + //constructors... + Createcircle_3p tr_createcircle_3p; + Createsegment_2p tr_createsegment_2p; + Createline_2p tr_createline_2p; + + + leda_edge cur_dart; + leda_edge hull_dart; + + bool check; // functions are checked if true + + // for marking nodes in search procedures + int cur_mark; + leda_node_map mark; + + void init_node_marks() + { mark.init(*this,-1); + cur_mark = 0; + } + + void mark_node(leda_node v) const + { ((leda_node_map&)mark)[v] = cur_mark; } + + void unmark_node(leda_node v) const + { ((leda_node_map&)mark)[v] = cur_mark - 1; } + + bool is_marked(leda_node v) const { return mark[v] == cur_mark; } + + void unmark_all_nodes() const + { ((int&)cur_mark)++; + if ( cur_mark == MAXINT) + ((Point_set_2*)this) -> init_node_marks(); + //cast away constness + } + + void mark_edge(leda_edge e, cgal_ps_delaunay_edge_info k) + { assign(e,k); } + + leda_node new_node(Point p) + { leda_node v = GRAPH::new_node(p); + mark[v] = -1; + return v; + } + + leda_edge new_edge(leda_node v, leda_node w) + { return GRAPH::new_edge(v,w,0); } + + leda_edge new_edge(leda_edge e, leda_node w) + { return GRAPH::new_edge(e,w,0,0); } + + void del_node(leda_node v) { GRAPH::del_node(v); } + void del_edge(leda_edge e) { GRAPH::del_edge(e); } + + + void init_hull(); + + void make_delaunay(leda_list& S); + + void make_delaunay(); + + void check_locate(leda_edge answer,const Point& p) const; + + void dfs(leda_node s, const Circle& C, leda_list& L) const; + + void dfs(leda_node s, const Point& pv, const Point& p, leda_list& L) const; + +public: + + Point_set_2() + { cur_dart = nil; + hull_dart = nil; + init_node_marks(); + check = false; + } + + Point_set_2(const leda_list& S) + { cur_dart = nil; + hull_dart = nil; + init_node_marks(); + check = false; + + init(S); + } + + Point_set_2(const std::list& S) + { cur_dart = nil; + hull_dart = nil; + init_node_marks(); + check = false; + + init(S); + } + + template + Point_set_2(InputIterator first, InputIterator last) + { cur_dart = nil; + hull_dart = nil; + init_node_marks(); + check = false; + + init(first,last); + } + + Point_set_2(const GRAPH& G) :GRAPH(G) + { + leda_edge e; + forall_edges(e,*this) mark_edge(e,CGAL_DIAGRAM_DART); + init_hull(); + make_delaunay(); + if (number_of_edges() > 0) + cur_dart = reversal(hull_dart); + else + cur_dart = nil; + init_node_marks(); + check = false; + } + + Point_set_2(const Point_set_2& T):GRAPH(T) + { + init_hull(); + if (number_of_edges() > 0) + cur_dart = reversal(hull_dart); + else + cur_dart = nil; + init_node_marks(); + check = false; + } + + Point_set_2& operator=(const Point_set_2& T) + { + GRAPH::operator=(T); + init_hull(); + if (number_of_edges() > 0) + cur_dart = reversal(hull_dart); + else + cur_dart = nil; + init_node_marks(); + check = false; + return *this; + } + + ~Point_set_2() {} + + void init(const leda_list& L0); + + void init(const std::list& L0); + + template + void init(InputIterator first, InputIterator last) + { + // construct a triangulation for the points in L0 + + clear(); + + if (first==last) return; + + leda_list L; + InputIterator it=first; + + for(;it!=last;++it){ + L.append(*it); + } + + L.sort(tr_comparepoints); + + // initialize graph with a single edge starting at the first point + + Point last_p = L.pop(); // last visited point + leda_node last_v = new_node(last_p); // last inserted node + + while (!L.empty() && last_p == L.head()) L.pop(); + + if (L.empty()) return; + + last_p = L.pop(); + leda_node v = new_node(last_p); + leda_edge x = new_edge(last_v,v); + leda_edge y = new_edge(v,last_v); + set_reversal(x,y); + last_v = v; + + + // scan remaining points + + Point p=last_p; // changed .... + forall(p,L) + { if (p == last_p) continue; + + leda_edge e = last_adj_edge(last_v); + + last_v = new_node(p); + last_p = p; + + // walk up to upper tangent + do e = face_cycle_pred(e); while (orientation(e,p) > 0); + + // walk down to lower tangent and triangulate + do { e = face_cycle_succ(e); + leda_edge x = new_edge(e,last_v); + leda_edge y = new_edge(last_v,source(e)); + set_reversal(x,y); + } while (orientation(e,p) > 0); + } + + // mark edges of convex hull + + hull_dart = last_edge(); + + cur_dart = reversal(hull_dart); + + leda_edge e0 = hull_dart; + leda_edge e = e0; + do { mark_edge(e,CGAL_HULL_DART); + e = face_cycle_succ(e); + } while (e != e0); + + make_delaunay(); + + init_node_marks(); + } + + leda_list points() const; + + template + OutputIterator points(OutputIterator out) + { + leda_node v; + forall_nodes(v,*this) { *out= pos(v); out++; } + return out; + } + + template + OutputIterator segments(OutputIterator out) + { + leda_edge e; + forall_edges(e,*this) { *out= seg(e); out++; } + return out; + } + + template + OutputIterator vertices(OutputIterator out) + { + leda_node v; + forall_nodes(v,*this) { *out= v; out++; } + return out; + } + + template + OutputIterator edges(OutputIterator out) + { + leda_edge e; + forall_edges(e,*this) { *out= e; out++; } + return out; + } + + Edge d_face_cycle_succ(Edge e) const + { e = reversal(e); + do e = cyclic_adj_pred(e); + while (!is_diagram_dart(e)); + return e; + } + + Edge d_face_cycle_pred(Edge e) const + { do e = cyclic_adj_succ(e); + while (!is_diagram_dart(e)); + return reversal(e); + } + + bool empty() { return number_of_nodes() == 0; } + + bool is_empty() { return number_of_nodes() == 0; } + + void clear() { GRAPH::clear(); cur_dart = hull_dart = nil; } + + Edge locate(Point p) const; + + Vertex lookup(Point p) const; + + Vertex insert(Point p); + + void del(Vertex v); + + void del(Point p); + + Vertex nearest_neighbor(Point p); + + Vertex nearest_neighbor(Vertex v) const; + + Vertex nearest_neighborA(Vertex v) const; + + Vertex nearest_neighborD(Point p) const; + + template + OutputIterator nearest_neighbors(Point p, int k,OutputIterator res) + { leda_list result; + int n = number_of_nodes(); + leda_node nd; + + if ( k <= 0 ) return res; + if ( n <= k ) { + result=all_nodes(); + forall(nd,result) { *res=nd; res++; } + return res; + } + + // insert p and search neighbors graph starting at p + + leda_node v = lookup(p); + bool old_node = true; + if ( v == nil ) + { v = ((Point_set_2*)this)->insert(p); + old_node = false; + k++; + } + + result = nearest_neighbors(v,k); + + if ( !old_node ) + { result.pop(); + ((Point_set_2*)this)->del(v); + } + + forall(nd,result) { *res=nd; res++; } + return res; + } + + leda_list nearest_neighbors(Point p, int k); + + template + OutputIterator nearest_neighbors(Vertex v, int k,OutputIterator res) const + { leda_list result; + int n = number_of_nodes(); + leda_node nd; + + if ( k <= 0 ) return res; + if ( n <= k ) { + result=all_nodes(); + forall(nd,result) { *res=nd; res++; } + return res; + } + + Point p = pos(v); + + unmark_all_nodes(); + + leda_p_queue PQ; + + PQ.insert(0,v); mark_node(v); + + while ( k > 0 ) + { pq_item it = PQ.find_min(); + leda_node w = PQ.inf(it); PQ.del_item(it); + + result.append(w); k--; + + leda_node z; + forall_adj_nodes(z,w) + { if ( !is_marked(z) ) + { PQ.insert(tr_sqrdist(p,pos(z)),z); + mark_node(z); + } + } + } + + forall(nd,result) { *res=nd; res++; } + return res; + } + + + leda_list nearest_neighbors(Vertex v, int k) const; + + template + OutputIterator range_search(const Circle& C, OutputIterator res) + { + leda_list L; + leda_node nd; + + //int orient = C.orientation(); // Achtung !!!!!!!! + //if (orient == 0) + // error_handler(1,"Point_set_2::range_search: circle must be proper"); + + if (number_of_nodes() == 0) return res; + if ( number_of_nodes() == 1 && !(tr_circleptori(C,pos(first_node()))==ON_UNBOUNDED_SIDE)) //changed + { //L.append(first_node()); + //return L; + *res=first_node(); res++; + return res; + } + + Point p = tr_circlecenter(C); + leda_node v = lookup(p); + bool new_v = false; + + if ( v == nil ) + { new_v = true; + v = insert(p); + } + + unmark_all_nodes(); + + dfs(v,C,L); + + if (new_v) + { L.pop(); + del(v); + } + + forall(nd,L){ *res=nd; res++; } + return res; + } + + leda_list range_search(const Circle& C); + + template + OutputIterator range_search(Vertex v,const Point& p, OutputIterator res) const + { + leda_list L; + + Point pv = pos(v); + + unmark_all_nodes(); + + dfs(v,pv,p,L); + + leda_node nd; + forall(nd,L){ *res=nd; res++; } + return res; + } + + + leda_list range_search(Vertex v,const Point& p) const; + + + template + OutputIterator range_search(const Point& a, const Point& b, const Point& c,OutputIterator res) + { int orient = (int)(tr_orientation(a,b,c)); + Circle C = tr_createcircle_3p(a,b,c); + leda_list L = range_search(C); + list_item it = L.first_item(); + while (it != nil) + { Point p = pos(L[it]); + list_item next_it = L.succ(it); + if ( ((int)(tr_orientation(a,b,p))) == - orient || + ((int)(tr_orientation(b,c,p))) == - orient || + ((int)(tr_orientation(c,a,p))) == - orient ) + L.del_item(it); + it = next_it; + } + leda_node nd; + + forall(nd,L){ *res=nd; res++; } + return res; + } + + leda_list range_search(const Point& a, const Point& b, const Point& c); + + + template + OutputIterator range_search(const Point& a1, const Point& b1, const Point& c1,const Point& + d1,OutputIterator res) + // a1 lower left, b1 lower right , c1 upper right + { + //Point b(c.xcoord(),a.ycoord()); + //Point d(a.xcoord(),c.ycoord()); + Point a=a1,b=b1,c=c1,d=d1; + + if (tr_orientation(a,b,c) == RIGHTTURN) + { Point tmp = b; + b = d; + d = tmp; + } + + //W.set_color(leda_red); + //W << a; W << b; W << c; + Circle C = tr_createcircle_3p(a,b,c); + //W << C; + + leda_list L = range_search(C); + + list_item it = L.first_item(); + while (it != nil) + { Point p = pos(L[it]); + list_item next_it = L.succ(it); + if ( tr_orientation(a,b,p) == RIGHTTURN || tr_orientation(b,c,p) == RIGHTTURN || + tr_orientation(c,d,p) == RIGHTTURN || tr_orientation(d,a,p) == RIGHTTURN ) + L.del_item(it); + it = next_it; + } + + leda_node nd; + forall(nd,L){ *res=nd; res++; } + return res; + } + + + leda_list rectangular_range_search(const Point& a1, const Point& b1, const Point& c1,const Point& d1); + + static const Point_set_2* T_tmp; + + static int cmp_edge_length(const leda_edge& e1, const leda_edge& e2) + { Numb_type l1 = T_tmp->tr_sqrdist(T_tmp->pos_source(e1),T_tmp->pos_target(e1)); + Numb_type l2 = T_tmp->tr_sqrdist(T_tmp->pos_source(e2),T_tmp->pos_target(e2)); +#if defined POINT_SET_LEDA_ONLY + return compare(l1,l2); +#else + return CGAL::compare(l1,l2); +#endif + } + + leda_list minimum_spanning_tree() const + { T_tmp = this; + return MIN_SPANNING_TREE(*this, Point_set_2::cmp_edge_length); + } + + template + OutputIterator minimum_spanning_tree(OutputIterator result) const + { + leda_list EL; + T_tmp = this; + EL=MIN_SPANNING_TREE(*this, Point_set_2::cmp_edge_length); + Edge e; + forall(e,EL) { *result = e; ++result; } + return result; + } + + void compute_voronoi(GRAPH& VD) const; + + void checking_on() + { check = true; } + + void checking_off() + { check = false; } + + bool check_state(const leda_string& location) const; + + bool IS_NON_DIAGRAM_DART(Edge e) const; + + bool is_non_diagram_edge(Edge e) const + { + return IS_NON_DIAGRAM_DART(e); + } + + Edge get_cur_dart() const { return cur_dart; } + void set_cur_dart(Edge e) { cur_dart = e; } + void set_hull_dart(Edge e) { hull_dart = e; } + + Point pos(Vertex v) const + { return inf(v); } + + Point pos_source(Edge e) const + { return inf(source(e)); } + + Point pos_target(Edge e) const + { return inf(target(e)); } + + Segment seg(Edge e) const + { return tr_createsegment_2p(inf(source(e)),inf(target(e))); } + + Line supporting_line(Edge e) const + { return tr_createline_2p(inf(source(e)),inf(target(e))); } + + Edge get_hull_dart() const + { return hull_dart; } + + Edge get_hull_edge() const + { return hull_dart; } + + bool is_diagram_dart(Edge e) const + { return !(inf(e) & CGAL_NON_DIAGRAM_DART); } + + bool is_diagram_edge(Edge e) const + { return is_diagram_dart(e); } + + bool is_hull_dart(Edge e) const + { return inf(e) & CGAL_HULL_DART; } + + bool is_hull_edge(Edge e) const + { return is_hull_dart(e); } + + int orientation(Edge e, Point p) const + { return ((int)tr_orientation(pos(source(e)),pos(target(e)),p)); } + + int dim() const + { int n = number_of_nodes(); + if (n <= 1) + return n - 1; + else + return (is_hull_dart(reversal(hull_dart))) ? 1 : 2 ; + } + +}; + +template const Point_set_2* Point_set_2::T_tmp; + + + +// Impl. ... + + template + void Point_set_2::init_hull() + { + hull_dart = nil; + + leda_edge e; + forall_edges(e,*this) + { if ( orientation(e,pos_target(face_cycle_succ(e))) <= 0 ) + { hull_dart = e; + break; + } + } + + if (hull_dart) + { leda_edge e = hull_dart; + do { mark_edge(e,CGAL_HULL_DART); + e = face_cycle_succ(e); + } + while (e != hull_dart); + } + } + + template + void Point_set_2::make_delaunay(leda_list& S) + { + // Transforms graph into a Delaunay triangulation by flipping edges. + // Diagonals of co-circular convex quadrilaterals are marked as + // CGAL_NON_DIAGRAM_DART + // We maintain a stack $S$ of edges containing diagonals which might + // have to be flipped. + + if (number_of_nodes() <= 3) return; + + while ( !S.empty() ) + { leda_edge e = S.pop(); + leda_edge r = reversal(e); + + if (is_hull_dart(e) || is_hull_dart(r)) continue; + + mark_edge(e,CGAL_DIAGRAM_DART); + mark_edge(r,CGAL_DIAGRAM_DART); + + // e1,e2,e3,e4: edges of quadrilateral with diagonal e + leda_edge e1 = face_cycle_succ(r); + leda_edge e3 = face_cycle_succ(e); + + // flip test + Point a = pos_source(e1); + Point b = pos_target(e1); + Point c = pos_source(e3); + Point d = pos_target(e3); + + if ((tr_orientation(b,d,a)==LEFTTURN) && (tr_orientation(b,d,c)==RIGHTTURN) ) + { // the quadrilateral is convex + int soc = (int)(tr_so_circle(a,b,c,d)); + + if (soc == 0) // co-circular quadrilateral(a,b,c,d) + { mark_edge(e,CGAL_NON_DIAGRAM_DART); + mark_edge(r,CGAL_NON_DIAGRAM_DART); + } + if (soc > 0) // flip + { leda_edge e2 = face_cycle_succ(e1); + leda_edge e4 = face_cycle_succ(e3); + + S.push(e1); + S.push(e2); + S.push(e3); + S.push(e4); + + // flip diagonal + move_edge(e,e2,source(e4)); + move_edge(r,e4,source(e2)); + } + } + } + + } + + template + void Point_set_2::make_delaunay() + { leda_list S = all_edges(); + make_delaunay(S); + } + + template + void Point_set_2::check_locate(leda_edge answer,const Point& p) const + { + if (answer == nil && dim() < 1) return; + + if ( tr_seg_contains(seg(answer),p) && ( is_hull_dart(answer) + || (!is_hull_dart(answer) && !is_hull_dart(reversal(answer)) ))) + return; + + if (orientation(answer,p) < 0) + { std::cerr << "\norientation(" << seg(answer) << "," << p << ") < 0."; + goto error_in_locate; + } + + if ( is_hull_dart(answer) && orientation(answer,p) > 0 ) return; + + if (dim() == 1) + { // orientation = 0 and answer does not contain p; so beyond extreme point + leda_edge e = face_cycle_succ(answer); + if ( e == reversal(answer) && !( ((int)(tr_so_hp(pos_source(e),pos_target(e),p))) >= 0 ) ) + return; + else + { std::cerr << "\n\ndim = 1 error."; + goto error_in_locate; + } + } + + // dim == 2: answer must not be a hull edge and triangle must contain p + if ( orientation(answer,p) > 0 && + orientation(face_cycle_succ(answer), p) > 0 && + orientation(face_cycle_pred(answer), p) > 0 ) + return; + else + { std::cerr << "\n\ndim = 2 error"; + goto error_in_locate; + } + + error_in_locate: + + std::cerr << "\nAn error occurred in Point_set_2::locate(point)."; + + exit(1); + } + + template + void Point_set_2::dfs(leda_node s, const Circle& C, leda_list& L) const + /* a procedure used in range_search(const Circle& C) */ + { L.append(s); + mark_node(s); + leda_node u; + forall_adj_nodes(u,s) + if (!is_marked(u) && ! (tr_circleptori(C,pos(u))==ON_UNBOUNDED_SIDE) ) dfs(u,C,L); //was C.outside + } + + template + void Point_set_2::dfs(leda_node s, const Point& pv, const Point& p, leda_list& L) const + /* a procedure used in range_search(leda_node v, const Point& p) */ + { L.append(s); + mark_node(s); + leda_node u; + forall_adj_nodes(u,s) + if (!is_marked(u)){ + Comparison_result cr = tr_comparedist(pv,pos(u),p); + if (cr==SMALLER || cr==EQUAL) dfs(u,pv,p,L); + } + } + + template + void Point_set_2::init(const leda_list& L0) + { + // construct a triangulation for the points in L0 + + clear(); + + if (L0.empty()) return; + + leda_list L = L0; + + L.sort(tr_comparepoints); + + // initialize graph with a single edge starting at the first point + + Point last_p = L.pop(); // last visited point + leda_node last_v = new_node(last_p); // last inserted node + + while (!L.empty() && last_p == L.head()) L.pop(); + + if (L.empty()) return; + + last_p = L.pop(); + leda_node v = new_node(last_p); + leda_edge x = new_edge(last_v,v); + leda_edge y = new_edge(v,last_v); + set_reversal(x,y); + last_v = v; + + + // scan remaining points + + Point p=last_p; // changed .... + forall(p,L) + { if (p == last_p) continue; + + leda_edge e = last_adj_edge(last_v); + + last_v = new_node(p); + last_p = p; + + // walk up to upper tangent + do e = face_cycle_pred(e); while (orientation(e,p) > 0); + + // walk down to lower tangent and triangulate + do { e = face_cycle_succ(e); + leda_edge x = new_edge(e,last_v); + leda_edge y = new_edge(last_v,source(e)); + set_reversal(x,y); + } while (orientation(e,p) > 0); + } + + // mark edges of convex hull + + hull_dart = last_edge(); + + cur_dart = reversal(hull_dart); + + leda_edge e0 = hull_dart; + leda_edge e = e0; + do { mark_edge(e,CGAL_HULL_DART); + e = face_cycle_succ(e); + } while (e != e0); + + make_delaunay(); + + init_node_marks(); + } + + template + void Point_set_2::init(const std::list& L0) + { + // construct a triangulation for the points in L0 + + clear(); + + if (L0.empty()) return; + + leda_list L; + +#if defined(__GNUC__) + typename std::list::const_iterator it; +#else + std::list::const_iterator it; +#endif + + it = L0.begin(); + + for(;it != L0.end(); ++it) L.append(*it); + + L.sort(tr_comparepoints); + + // initialize graph with a single edge starting at the first point + + Point last_p = L.pop(); // last visited point + leda_node last_v = new_node(last_p); // last inserted node + + while (!L.empty() && last_p == L.head()) L.pop(); + + if (L.empty()) return; + + last_p = L.pop(); + leda_node v = new_node(last_p); + leda_edge x = new_edge(last_v,v); + leda_edge y = new_edge(v,last_v); + set_reversal(x,y); + last_v = v; + + + // scan remaining points + + Point p=last_p; // changed .... + forall(p,L) + { if (p == last_p) continue; + + leda_edge e = last_adj_edge(last_v); + + last_v = new_node(p); + last_p = p; + + // walk up to upper tangent + do e = face_cycle_pred(e); while (orientation(e,p) > 0); + + // walk down to lower tangent and triangulate + do { e = face_cycle_succ(e); + leda_edge x = new_edge(e,last_v); + leda_edge y = new_edge(last_v,source(e)); + set_reversal(x,y); + } while (orientation(e,p) > 0); + } + + // mark edges of convex hull + + hull_dart = last_edge(); + + cur_dart = reversal(hull_dart); + + leda_edge e0 = hull_dart; + leda_edge e = e0; + do { mark_edge(e,CGAL_HULL_DART); + e = face_cycle_succ(e); + } while (e != e0); + + make_delaunay(); + + init_node_marks(); + } + + template + leda_list::Point> Point_set_2::points() const + { leda_list L; + leda_node v; + forall_nodes(v,*this) L.append(pos(v)); + return L; + } + + template + Point_set_2::Edge + Point_set_2::locate(Point p) const + { + if (number_of_edges() == 0) return nil; + + if (dim() == 1) + { + leda_edge e = hull_dart; + int orient = orientation(e,p); + if (orient != 0) + { if (orient < 0) e = reversal(e); + if (check) check_locate(e ,p); + return e; + } + + // p is collinear with the points in S. We walk + + if ( !(((int) (tr_so_hp(pos_source(e),pos_target(e),p))) >= 0 ) ) e = reversal(e); + + // in the direction of e. We know IN_HALFSPACE(e,p) + + leda_edge e1 = face_cycle_succ(e); + while ( e1 != reversal(e) && ( ((int)(tr_so_hp(pos_source(e1),pos_target(e1),p))) >= 0 ) ) + { e = e1; + e1 = face_cycle_succ(e); + } + + if (check) check_locate(e ,p); + + return e; + } + + + leda_edge e = is_hull_dart(cur_dart) ? reversal(cur_dart) : cur_dart; + + if (p == pos_source(e) ) return reversal(e); + + int orient = orientation(e,p); + + if (orient == 0) + { e = face_cycle_pred(e); + orient = orientation(e,p); + } + + if (orient < 0) e = reversal(e); + + //Segment s(pos_source(e),p); + Point ps1=pos_source(e); + Point ps2=p; + + while ( true ) + { + if (is_hull_dart(e)) break; + + leda_edge e1 = face_cycle_succ(e); + leda_edge e2 = face_cycle_pred(e); + Orientation ori = tr_orientation(ps1,ps2,pos_target(e1)); + int d= (int)ori; + leda_edge e_next = reversal( (d < 0) ? e2 : e1 ); + int orient = orientation(e_next,p); + if ( orient > 0 ) { e = e_next; continue; } + if ( orient == 0 ) { e = e_next; break; } + if ( d == 0 && orient < 0 && orientation(e2,p) == 0 ) + e = reversal(e2); + break; + + } + + if (check) check_locate(e ,p); + + ((leda_edge&)cur_dart) = e; + return e; + } + + template + Point_set_2::Vertex + Point_set_2::lookup(Point p) const + { + if (number_of_nodes() == 0) return nil; + + if (number_of_nodes() == 1) + { leda_node v = first_node(); + return (pos(v) == p) ? v : nil; + } + leda_edge e = locate(p); + if (pos(source(e)) == p) return source(e); + if (pos(target(e)) == p) return target(e); + return nil; + } + + template + Point_set_2::Vertex + Point_set_2::insert(Point p) + { + leda_node v; + + if (number_of_nodes() == 0) + { v = new_node(p); + if ( check && !check_state("Point_set_2::insert") ) + { std::cerr << "The point inserted was " << p; + exit(1); + } + return v; + } + + if (number_of_nodes() == 1) + { leda_node w = first_node(); + if (p == pos(w)) + { assign(w,p); + v = w; + + if ( check && !check_state("Point_set_2::insert") ) + { std::cerr << "The point inserted was " << p; + exit(1); + } + return v; + + } + else + { v = new_node(p); + leda_edge x = new_edge(v,w); + leda_edge y = new_edge(w,v); + mark_edge(x,CGAL_HULL_DART); + mark_edge(y,CGAL_HULL_DART); + set_reversal(x,y); + hull_dart = x; + cur_dart = x; + + if ( check && !check_state("Point_set_2::insert") ) + { std::cerr << "The point inserted was " << p; + exit(1); + } + return v; + + } + } + + + leda_edge e = locate(p); + if (p == pos_source(e)) + { assign(source(e),p); return source(e); } + if (p == pos_target(e)) + { assign(target(e),p); return target(e); } + + bool p_on_e = tr_seg_contains(seg(e),p); + + + if ( dim() == 1 && orientation(e,p) == 0 ) + { + v = new_node(p); + leda_edge x = new_edge(v,target(e)); + leda_edge y = new_edge(target(e),v); + mark_edge(x,CGAL_HULL_DART); + mark_edge(y,CGAL_HULL_DART); + set_reversal(x,y); + + if (p_on_e) + { x = new_edge(v,source(e)); + y = new_edge(source(e),v); + mark_edge(x,CGAL_HULL_DART); + mark_edge(y,CGAL_HULL_DART); + set_reversal(x,y); + hull_dart = cur_dart = x; + + del_edge(reversal(e)); + del_edge(e); + } + + + if ( check && !check_state("Point_set_2::insert") ) + { std::cerr << "The point inserted was " << p; + exit(1); + } + return v; + + } + + v = new_node(p); + leda_edge e1 = e; + leda_edge e2 = e; + leda_list E; + bool outer_face = is_hull_dart(e); + + if (outer_face) // move e1/e2 to compute upper/lower tangents + { do e1 = face_cycle_pred(e1); while (orientation(e1,p) > 0); + do e2 = face_cycle_succ(e2); while (orientation(e2,p) > 0); + } + + // insert edges between v and target(e1) ... source(e2) + e = e1; + do { e = face_cycle_succ(e); + leda_edge x = new_edge(e,v); + leda_edge y = new_edge(v,source(e)); + set_reversal(x,y); + mark_edge(e,CGAL_DIAGRAM_DART); + E.append(e); + E.append(x); + } while (e != e2); + + if (outer_face) // mark last visited and new edges as hull edges + { mark_edge(face_cycle_succ(e1),CGAL_HULL_DART); + mark_edge(face_cycle_pred(e2),CGAL_HULL_DART); + mark_edge(e2,CGAL_HULL_DART); + hull_dart = e2; + } + + make_delaunay(E); // restores Delaunay property + + if ( check && !check_state("Point_set_2::insert") ) + { std::cerr << "The point inserted was " << p; + exit(1); + } + return v; + + } + + + template + void Point_set_2::del(Vertex v) + { + if (v == nil) + error_handler(1,"Point_set_2::del: nil argument."); + + if (number_of_nodes() == 0) + error_handler(1,"Point_set_2::del: graph is empty."); + + if ( dim() < 2 ) + { + if ( outdeg(v) == 2) + { leda_node s = target(first_adj_edge(v)); + leda_node t = target(last_adj_edge(v)); + leda_edge x = new_edge(s,t); + leda_edge y = new_edge(t,s); + mark_edge(x,CGAL_HULL_DART); + mark_edge(y,CGAL_HULL_DART); + set_reversal(x,y); + } + + del_node(v); + cur_dart = hull_dart = first_edge(); + + + if ( check && !check_state("Point_set_2::del(node v)") ) + { std::cerr << "deleted the node with position " << pos(v); + exit(1); + } + return; + + } + + leda_list E; + + int min_deg = 3; + + leda_edge e; + forall_adj_edges(e,v) + { E.append(face_cycle_succ(e)); + if (is_hull_dart(e)) min_deg = 2; + } + + int count = 0; + e = first_adj_edge(v); + + while ( outdeg(v) > min_deg && count < outdeg(v) ) + { leda_edge e_pred = cyclic_adj_pred(e); + leda_edge e_succ = cyclic_adj_succ(e); + Point a = pos_target(e_pred); Point c = pos_target(e_succ); + + if ( ! (tr_orientation(a,c,pos(v))==RIGHTTURN) && (tr_orientation(a,c,pos_target(e))==RIGHTTURN) ) + { // e is flipable + leda_edge r = reversal(e); + + move_edge(e,reversal(e_succ),target(e_pred)); + +#if (__LEDA__ > 371) + move_edge(r,reversal(e_pred),target(e_succ),LEDA::before); +#else + move_edge(r,reversal(e_pred),target(e_succ),leda_before); +#endif + + mark_edge(e,CGAL_DIAGRAM_DART); + mark_edge(r,CGAL_DIAGRAM_DART); + E.append(e); + + e = e_pred; + count = count - 2; + if ( count < 0 ) count = 0; + } + else + { e = e_succ; + count++; + } + } + + if ( min_deg == 2 ) + { + leda_edge e,x=NULL; // = NULL to supress warning + forall_adj_edges(e,v) + { x = face_cycle_succ(e); + mark_edge(x,CGAL_HULL_DART); + if ( !is_hull_dart(reversal(x)) ) + mark_edge(reversal(x),CGAL_DIAGRAM_DART); + } + hull_dart = x; + } + + cur_dart = E.head(); + + del_node(v); + make_delaunay(E); + + + + if ( check && !check_state("Point_set_2::del(node v)") ) + { std::cerr << "deleted the node with position " << pos(v); + exit(1); + } + return; + + } + + template + void Point_set_2::del(Point p) + { leda_node v = lookup(p); + if ( v != nil ) del(v); + } + + + template + Point_set_2::Vertex + Point_set_2::nearest_neighbor(Point p) + { + if (number_of_nodes() == 0) return nil; + + leda_node v = lookup(p); + leda_node min_v; + + if ( v != nil ) return v; + + // insert p and search neighbors of v + + leda_node w = insert(p); + + min_v = nearest_neighbor(w); + + del(w); + + return min_v; + } + + + template + Point_set_2::Vertex + Point_set_2::nearest_neighbor(Vertex v) const + { + if (number_of_nodes() <= 1) return nil; + + Point p = pos(v); + leda_edge e = first_adj_edge(v); + + leda_node min_v = target(e); + + while ((e = adj_succ(e)) != nil) + { leda_node u = target(e); + if ( tr_comparedist(p,pos(u),pos(min_v)) == SMALLER ) min_v = u; + } + + return min_v; + } + + template + Point_set_2::Vertex + Point_set_2::nearest_neighborA(Vertex v) const + { + if (number_of_nodes() <= 1) return nil; + + Point p = pos(v); + leda_edge e = first_adj_edge(v); + + + leda_node min_v = target(e); + Numb_type min_d = tr_sqrdist(p,pos(min_v)); + + while ((e = adj_succ(e)) != nil) + { leda_node u = target(e); + Numb_type d_u = tr_sqrdist(p,pos(u)); + if ( d_u < min_d ) + { min_v = u; + min_d = d_u; + } + } + + return min_v; + } + + template + Point_set_2::Vertex + Point_set_2::nearest_neighborD(Point p) const + { + if (number_of_nodes() == 0) return nil; + if (number_of_nodes() == 1) return first_node(); + + leda_edge e = locate(p); + + if ( is_hull_dart(e) ) + { while ( ! ( ((int)( tr_so_hp(pos_source(e),pos_target(e),p))) >= 0 ) ) e = face_cycle_pred(e); + while ( ! ( ((int)( tr_so_hp(pos_source(reverse(e)),pos_target(reverse(e)),p)) >= 0 ) )) e = face_cycle_succ(e); + } + + unmark_all_nodes(); + + leda_node min_v = source(e); + Numb_type min_d = tr_sqrdist(p,pos(min_v)); + + leda_list L; + L.append(source(e)); + L.append(target(e)); + mark_node(source(e)); + mark_node(target(e)); + + while ( !L.empty() ) + { leda_node v = L.pop(); + + if ( tr_sqrdist(p,pos(v)) < min_d ) + { min_v = v; + min_d = tr_sqrdist(p,pos(v)); + } + + forall_adj_edges(e,v) + { leda_node w = target(e); + if ( !is_marked(target(e)) && + ( ((int)(tr_so_hp(pos_source(e),pos_target(e),p))) >= 0 ) && \ + (((int)(tr_so_hp(pos_source(reversal(e)),pos_target(reversal(e)),p)) >= 0 )) && \ + tr_linesqrdist(supporting_line(e),p) < min_d ) + { L.append(w); + mark_node(w); + } + } + } + + return min_v; + + } + + + template + leda_list::Vertex> + Point_set_2::nearest_neighbors(Point p, int k) + { leda_list result; + int n = number_of_nodes(); + + if ( k <= 0 ) return result; + if ( n <= k ) return all_nodes(); + + // insert p and search neighbors graph starting at p + + leda_node v = lookup(p); + bool old_node = true; + if ( v == nil ) + { v = ((Point_set_2*)this)->insert(p); + old_node = false; + k++; + } + + result = nearest_neighbors(v,k); + + if ( !old_node ) + { result.pop(); + ((Point_set_2*)this)->del(v); + } + + return result; + } + + + template + leda_list::Vertex> + Point_set_2::nearest_neighbors(Vertex v, int k) const + { leda_list result; + int n = number_of_nodes(); + + if ( k <= 0 ) return result; + if ( n <= k ) return all_nodes(); + + Point p = pos(v); + + unmark_all_nodes(); + + leda_p_queue PQ; + + PQ.insert(0,v); mark_node(v); + + while ( k > 0 ) + { pq_item it = PQ.find_min(); + leda_node w = PQ.inf(it); PQ.del_item(it); + + result.append(w); k--; + + leda_node z; + forall_adj_nodes(z,w) + { if ( !is_marked(z) ) + { PQ.insert(tr_sqrdist(p,pos(z)),z); + mark_node(z); + } + } + } + + return result; + } + + + template + leda_list::Vertex> + Point_set_2::range_search(const Circle& C) + { + leda_list L; + + //int orient = C.orientation(); // Achtung !!!!!!!! + //if (orient == 0) + // error_handler(1,"Point_set_2::range_search: circle must be proper"); + + if (number_of_nodes() == 0) return L; + if ( number_of_nodes() == 1 && !(tr_circleptori(C,pos(first_node()))==ON_UNBOUNDED_SIDE )) //changed + { L.append(first_node()); + return L; + } + + Point p = tr_circlecenter(C); + leda_node v = lookup(p); + bool new_v = false; + + if ( v == nil ) + { new_v = true; + v = insert(p); + } + + unmark_all_nodes(); + + dfs(v,C,L); + + if (new_v) + { L.pop(); + del(v); + } + return L; + } + + template + leda_list::Vertex> + Point_set_2::range_search(Vertex v,const Point& p) const + { + leda_list L; + + Point pv = pos(v); + + unmark_all_nodes(); + + dfs(v,pv,p,L); + + return L; + } + + template + leda_list::Vertex> + Point_set_2::range_search(const Point& a, const Point& b, const Point& c) + { int orient = (int)(tr_orientation(a,b,c)); + Circle C = tr_createcircle_3p(a,b,c); + leda_list L = range_search(C); + list_item it = L.first_item(); + while (it != nil) + { Point p = pos(L[it]); + list_item next_it = L.succ(it); + if ( ((int)(tr_orientation(a,b,p))) == - orient || + ((int)(tr_orientation(b,c,p))) == - orient || + ((int)(tr_orientation(c,a,p))) == - orient ) + L.del_item(it); + it = next_it; + } + return L; + } + + template + leda_list::Vertex> + Point_set_2::rectangular_range_search(const Point& a1, const Point& b1, const Point& c1,const Point& d1) + { + //Point b(c.xcoord(),a.ycoord()); + //Point d(a.xcoord(),c.ycoord()); + Point a=a1,b=b1,c=c1,d=d1; + + if (tr_orientation(a,b,c) == RIGHTTURN) + { Point tmp = b; + b = d; + d = tmp; + } + + Circle C = tr_createcircle_3p(a,b,c); + + leda_list L = range_search(C); + list_item it = L.first_item(); + while (it != nil) + { Point p = pos(L[it]); + list_item next_it = L.succ(it); + if ( tr_orientation(a,b,p) == RIGHTTURN || tr_orientation(b,c,p) == RIGHTTURN || + tr_orientation(c,d,p) == RIGHTTURN || tr_orientation(d,a,p) == RIGHTTURN ) + L.del_item(it); + it = next_it; + } + return L; + } + + template + void Point_set_2::compute_voronoi(GRAPH& VD) const + { + VD.clear(); + + if (number_of_nodes() < 2) return; + + // create Voronoi nodes + + leda_edge_array vnode(*this,nil); + + // for outer face + + leda_edge e = hull_dart; + Point a = pos_source(e); + leda_edge x = e; + do { Point b = pos_target(x); + vnode[x] = VD.new_node(tr_createcircle_3p(a,a,b)); // midpoint has to be changed (was midpoint(a,b) instead of a + a = b; + x = face_cycle_succ(x); + } while ( x != e); + + // for all other faces + + forall_edges(e,*this) + { + if (vnode[e] || !is_diagram_dart(e)) continue; + + leda_edge x = face_cycle_succ(e); + Point a = pos_source(e); + Point b = pos_target(e); + Point c = pos_target(x); + leda_node v = VD.new_node(tr_createcircle_3p(a,b,c)); + + x = e; + do { vnode[x] = v; + x = d_face_cycle_succ(x); + } while( x != e); + } + + // construct Voronoi edges + + // for outer face + + e = hull_dart; + x = e; + do { leda_edge r = reversal(x); + Point p = pos_target(x); + VD.new_edge(vnode[x],vnode[r],p); + x = cyclic_adj_pred(r); + } while ( x != e); + + // for all other faces + + forall_edges(e,*this) + { leda_node v = vnode[e]; + + if (!is_diagram_dart(e) || VD.outdeg(v) > 0) continue; + + Point p = pos_target(e); + leda_edge x = e; + do { leda_edge r = reversal(x); + VD.new_edge(v,vnode[r],p); + x = d_face_cycle_succ(x); + } while (x != e); + } + // add a check for correctness + } + + template + bool Point_set_2::check_state(const leda_string& location) const + { + if ( !check ) return true; + + write("Point_set_2_error.graph_after_op"); + + // check hull_dart and cur_dar + if ( (hull_dart == nil || cur_dart == nil) + && (number_of_nodes() >= 2) ) + { std::cerr << "\nhull_dart or cur_dart contradicts number of nodes\n"; + + std::cerr << "\n\nCheck_state was called at " << location; + std::cerr << "\n\nThe situation before the call of " << location; + std::cerr << "\nwas saved into files Point_set_2_error.graph"; + std::cerr << "\nand Point_set_2_error.aux."; + std::cerr << "\n\nPlease send these files to ledares@mpi-sb.mpg.de.\n\n"; + + return false; + + } + if ( hull_dart == nil ) return true; + + // check edge labels + leda_edge e; + forall_edges(e,*this) + { switch ( inf(e)) { + + case CGAL_HULL_DART: + { leda_edge next = face_cycle_succ(e); + int orient = orientation(e,pos_target(next)); + if ( orient > 0 ) + { std::cerr << "\n\nwrongly labeled hull_dart."; + + std::cerr << "\n\nCheck_state was called at " << location; + std::cerr << "\n\nThe situation before the call of " << location; + std::cerr << "\nwas saved into files Point_set_2_error.graph"; + std::cerr << "\nand Point_set_2_error.aux."; + std::cerr << "\n\nPlease send these files to ledares@mpi-sb.mpg.de.\n\n"; + + return false; + + } + break; + } + + case CGAL_DIAGRAM_DART: + { if ( inf(reversal(e)) != CGAL_HULL_DART && + IS_NON_DIAGRAM_DART(e) ) + { std::cerr << "\n\nwrongly labeled diagram_dart."; + + std::cerr << "\n\nCheck_state was called at " << location; + std::cerr << "\n\nThe situation before the call of " << location; + std::cerr << "\nwas saved into files Point_set_2_error.graph"; + std::cerr << "\nand Point_set_2_error.aux."; + std::cerr << "\n\nPlease send these files to ledares@mpi-sb.mpg.de.\n\n"; + + return false; + + } + break; + } + + case CGAL_NON_DIAGRAM_DART: + { if ( inf(reversal(e)) != CGAL_NON_DIAGRAM_DART || + !IS_NON_DIAGRAM_DART(e) ) + { std::cerr << "\n\nwrongly labeled non_diagram_dart."; + + std::cerr << "\n\nCheck_state was called at " << location; + std::cerr << "\n\nThe situation before the call of " << location; + std::cerr << "\nwas saved into files Point_set_2_error.graph"; + std::cerr << "\nand Point_set_2_error.aux."; + std::cerr << "\n\nPlease send these files to ledares@mpi-sb.mpg.de.\n\n"; + + return false; + + } + break; + } + + + default: std::cerr << "\n\nillegal edge label."; + + std::cerr << "\n\nCheck_state was called at " << location; + std::cerr << "\n\nThe situation before the call of " << location; + std::cerr << "\nwas saved into files Point_set_2_error.graph"; + std::cerr << "\nand Point_set_2_error.aux."; + std::cerr << "\n\nPlease send these files to ledares@mpi-sb.mpg.de.\n\n"; + + return false; + + } + } + + if ( inf(hull_dart) != CGAL_HULL_DART ) + { std::cerr << "\n\nis_hull_dart gives wrong information."; + + std::cerr << "\n\nCheck_state was called at " << location; + std::cerr << "\n\nThe situation before the call of " << location; + std::cerr << "\nwas saved into files Point_set_2_error.graph"; + std::cerr << "\nand Point_set_2_error.aux."; + std::cerr << "\n\nPlease send these files to ledares@mpi-sb.mpg.de.\n\n"; + + return false; + + } + return true; + } + + template + bool Point_set_2::IS_NON_DIAGRAM_DART(Edge e) const + { leda_edge r = reversal(e); + + // e1,e2,e3,e4: edges of quadrilateral with diagonal e + leda_edge e1 = face_cycle_succ(r); + leda_edge e3 = face_cycle_succ(e); + + // flip test + Point a = pos_source(e1); + Point b = pos_target(e1); + Point c = pos_source(e3); + Point d = pos_target(e3); + + if ((tr_orientation(a,b,c)==LEFTTURN) && (tr_orientation(b,c,d)==LEFTTURN) && + (tr_orientation(c,d,a)==LEFTTURN) && (tr_orientation(d,a,c)==LEFTTURN) && + (tr_so_circle(a,b,c,d)==ON_ORIENTED_BOUNDARY) ) + return true; + return false; + } + + +CGAL_END_NAMESPACE + + + +#if LEDA_ROOT_INCL_ID == 400900 +#undef LEDA_ROOT_INCL_ID +#include +#endif + + +#endif + diff --git a/Packages/Point_set_2/include/CGAL/point_set_leda_traits_2.h b/Packages/Point_set_2/include/CGAL/point_set_leda_traits_2.h new file mode 100644 index 00000000000..b64a1163500 --- /dev/null +++ b/Packages/Point_set_2/include/CGAL/point_set_leda_traits_2.h @@ -0,0 +1,296 @@ +// ====================================================================== +// +// Copyright (c) 1999 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------- +// +// release : +// release_date : 2000, September 14 +// +// file : include/CGAL/point_set_leda_traits_2.h +// package : Point_set_2 (1.2.4) +// maintainer : Matthias Baesken +// revision : 1.2.4 +// revision_date : 14 September 2000 +// author(s) : Kurt Mehlhorn, Stefan Naeher, Matthias Baesken +// +// coordinator : Matthias Baesken, Halle () +// ====================================================================== + +#ifndef POINT_SET_2_LEDA_TRAITS +#define POINT_SET_2_LEDA_TRAITS + +#if !defined(LEDA_ROOT_INCL_ID) +#define LEDA_ROOT_INCL_ID 400899 +#include +#endif + +#include +#include +#include +#include + +#include +#include +#include +#include + +CGAL_BEGIN_NAMESPACE + +class Leda_compare_ratpoints : public leda_cmp_base { + int operator()(const leda_rat_point& p1,const leda_rat_point& p2) const + { + return leda_rat_point::cmp_xy(p1,p2); + } +}; + +class Leda_compare_points : public leda_cmp_base { + int operator()(const leda_point& p1,const leda_point& p2) const + { + return leda_point::cmp_xy(p1,p2); + } +}; + +template +struct Leda_compare_dist { + Comparison_result operator()(const T& p1,const T& p2,const T& p3) const + { + int c = p1.cmp_dist(p2,p3); + switch (c){ + case -1: return SMALLER; + case 0 : return EQUAL; + } + return LARGER; + } +}; + +template +struct Leda_orientation { + Orientation operator()(const T& p1,const T& p2,const T& p3) const + { + int o = ::orientation(p1,p2,p3); + switch(o){ + case -1: return RIGHTTURN; + case 0: return COLLINEAR; + } + return LEFTTURN; + } +}; + +template +struct Leda_side_of_circle { + Oriented_side operator()(const T& p1,const T& p2,const T& p3, const T& p4) const + { + int s = side_of_circle(p1,p2,p3,p4); + switch(s){ + case -1: return ON_NEGATIVE_SIDE; + case 0: return ON_ORIENTED_BOUNDARY; + } + return ON_POSITIVE_SIDE; + } +}; + +template +struct Leda_side_of_halfspace { + Orientation operator()(const T& p1,const T& p2, const T& p3) const + { + int o = side_of_halfspace(p1,p2,p3); + switch(o){ + case -1: return RIGHTTURN; + case 0: return COLLINEAR; + } + return LEFTTURN; + } +}; + +template +struct Leda_segment_contains { + bool operator()(const S& seg, const T& p) const + { return seg.contains(p); } +}; + +template +struct Leda_sqr_dist { + Rep operator()(const T& p1,const T& p2) const + { return p1.sqr_dist(p2); } +}; + +template +struct Leda_line_sqr_dist { + Rep operator()(const L& l,const T& p) const + { return l.sqr_dist(p); } +}; + +template +struct Leda_circle_ptori { + Bounded_side operator()(const C& c, const T& p) const + { int wt = c.orientation(); + int so = c.side_of(p); + int bs = wt*so; // <0 outside, ==0 on the circle, >0 inside + switch (bs){ + case -1: return ON_UNBOUNDED_SIDE; + case 0: return ON_BOUNDARY; + } + return ON_BOUNDED_SIDE; + } +}; + +template +struct Leda_circle_center { + T operator()(const C& c) const + { return c.center(); } +}; + + +template +struct Leda_create_circle_ppp { + C operator()(const T& p1,const T& p2,const T& p3) const + { return C(p1,p2,p3); } +}; + +template +struct Leda_create_segment_pp { + C operator()(const T& p1,const T& p2) const + { return C(p1,p2); } +}; + +template +struct Leda_create_line_pp { + C operator()(const T& p1,const T& p2) const + { return C(p1,p2); } +}; + + +class point_set_leda_float_traits_2 { + public: + typedef double FT; + typedef leda_point Point; + typedef leda_circle Circle; + typedef leda_segment Segment; + typedef leda_line Line; + + typedef Leda_compare_points Compare_xy_2; + typedef Leda_compare_dist Compare_dist_2; + typedef Leda_orientation Orientation; + typedef Leda_side_of_circle Side_of_oriented_circle_2; + typedef Leda_side_of_halfspace Side_of_halfspace_2; + typedef Leda_segment_contains Segment_has_on_2; + typedef Leda_sqr_dist Squared_distance; + typedef Leda_line_sqr_dist Squared_distance_to_line; + typedef Leda_circle_ptori Circle_bounded_side_2; + typedef Leda_circle_center Circle_center_2; + + typedef Leda_create_circle_ppp Construct_circle_2; + typedef Leda_create_segment_pp Construct_segment_2; + typedef Leda_create_line_pp Construct_line_2; + + Orientation get_orientation_object() const + { return Orientation(); } + + Side_of_oriented_circle_2 get_side_of_oriented_circle_2_object() const + { return Side_of_oriented_circle_2(); } + + Side_of_halfspace_2 get_side_of_halfspace_2_object() const + { return Side_of_halfspace_2(); } + + Segment_has_on_2 get_segment_has_on_2_object() const + { return Segment_has_on_2(); } + + Squared_distance get_squared_distance_object() const + { return Squared_distance(); } + + Squared_distance_to_line get_squared_distance_to_line_object() const + { return Squared_distance_to_line(); } + + Circle_bounded_side_2 get_circle_bounded_side_2_object() const + { return Circle_bounded_side_2(); } + + Circle_center_2 get_circle_center_2_object() const + { return Circle_center_2(); } + + Construct_circle_2 get_construct_circle_2_object() const + { return Construct_circle_2(); } + + Construct_segment_2 get_construct_segment_2_object() const + { return Construct_segment_2(); } + + Construct_line_2 get_construct_line_2_object() const + { return Construct_line_2(); } + + point_set_leda_float_traits_2() { } +}; + +class point_set_leda_rat_traits_2 { + public: + typedef leda_rational FT; + typedef leda_rat_point Point; + typedef leda_rat_circle Circle; + typedef leda_rat_segment Segment; + typedef leda_rat_line Line; + + typedef Leda_compare_ratpoints Compare_xy_2; + typedef Leda_compare_dist Compare_dist_2; + typedef Leda_orientation Orientation; + typedef Leda_side_of_circle Side_of_oriented_circle_2; + typedef Leda_side_of_halfspace Side_of_halfspace_2; + typedef Leda_segment_contains Segment_has_on_2; + typedef Leda_sqr_dist Squared_distance; + typedef Leda_line_sqr_dist Squared_distance_to_line; + typedef Leda_circle_ptori Circle_bounded_side_2; + typedef Leda_circle_center Circle_center_2; + + typedef Leda_create_circle_ppp Construct_circle_2; + typedef Leda_create_segment_pp Construct_segment_2; + typedef Leda_create_line_pp Construct_line_2; + + + Orientation get_orientation_object() const + { return Orientation(); } + + Side_of_oriented_circle_2 get_side_of_oriented_circle_2_object() const + { return Side_of_oriented_circle_2(); } + + Side_of_halfspace_2 get_side_of_halfspace_2_object() const + { return Side_of_halfspace_2(); } + + Segment_has_on_2 get_segment_has_on_2_object() const + { return Segment_has_on_2(); } + + Squared_distance get_squared_distance_object() const + { return Squared_distance(); } + + Squared_distance_to_line get_squared_distance_to_line_object() const + { return Squared_distance_to_line(); } + + Circle_bounded_side_2 get_circle_bounded_side_2_object() const + { return Circle_bounded_side_2(); } + + Circle_center_2 get_circle_center_2_object() const + { return Circle_center_2(); } + + Construct_circle_2 get_construct_circle_2_object() const + { return Construct_circle_2(); } + + Construct_segment_2 get_construct_segment_2_object() const + { return Construct_segment_2(); } + + Construct_line_2 get_construct_line_2_object() const + { return Construct_line_2(); } + + + point_set_leda_rat_traits_2() { } +}; + +CGAL_END_NAMESPACE + + +#if LEDA_ROOT_INCL_ID == 400899 +#undef LEDA_ROOT_INCL_ID +#include +#endif + +#endif diff --git a/Packages/Point_set_2/include/CGAL/point_set_traits_2.h b/Packages/Point_set_2/include/CGAL/point_set_traits_2.h new file mode 100644 index 00000000000..5a3c278f3e9 --- /dev/null +++ b/Packages/Point_set_2/include/CGAL/point_set_traits_2.h @@ -0,0 +1,238 @@ +// ====================================================================== +// +// Copyright (c) 1999 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------- +// +// release : +// release_date : 2000, September 14 +// +// file : include/CGAL/point_set_traits_2.h +// package : Point_set_2 (1.2.4) +// maintainer : Matthias Baesken +// revision : 1.2.4 +// revision_date : 14 September 2000 +// author(s) : Kurt Mehlhorn, Stefan Naeher, Matthias Baesken +// +// coordinator : Matthias Baesken, Halle () +// ====================================================================== + +#ifndef POINT_SET_2_TRAITS +#define POINT_SET_2_TRAITS + +#if !defined(LEDA_ROOT_INCL_ID) +#define LEDA_ROOT_INCL_ID 400898 +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +CGAL_BEGIN_NAMESPACE + + +#if defined(LEDA_PREFIX) +#undef vector +#endif + + + +template +class CG_Lex_xy : public leda_cmp_base { + int operator()(const T& p1,const T& p2) const + { + Comparison_result c = compare_lexicographically_xy(p1,p2); + switch(c){ + case SMALLER: return -1; + case LARGER: return 1; + case EQUAL: return 0; + } + return 0; + } +}; + +template +struct CG_compare_dist { + Comparison_result operator()(const T& p1,const T& p2,const T& p3) const + { + Comparison_result c= cmp_dist_to_point(p1,p2,p3); + return c; + } +}; + + +template +struct CG_orientation { + Orientation operator()(const T& p1,const T& p2,const T& p3) const + { + Orientation or=orientation(p1,p2,p3); + return or; + } +}; + +template +struct CG_side_of_circle { + int operator()(const T& p1,const T& p2,const T& p3, const T& p4) const + { + Oriented_side s= side_of_oriented_circle(p1,p2,p3,p4); + return s; + } +}; + +template +struct CG_side_of_halfspace { + typedef typename T::R Repres; + + Orientation operator()(const T& p1,const T& p2, const T& p3) const + { + Segment_2 s(p1,p2); + Direction_2 d = s.direction(); + + Vector_2 v(d.dx(),d.dy()); + Vector_2 v2= v.perpendicular(CLOCKWISE); + Point_2 ph = p1 + v2; + + Orientation or=orientation(p1,ph,p3); + return or; + } +}; + + +template +struct CG_segment_contains { + bool operator()(const S& seg, const T& p) const + { return seg.has_on(p); } +}; + +template +struct CG_sqr_dist { + Rep operator()(const T& p1,const T& p2) const + { return squared_distance(p1,p2); } +}; + + +template +struct CG_line_sqr_dist { + Rep operator()(const L& l,const T& p) const + { return squared_distance(l,p); } +}; + + +template +struct CG_circle_ptori { + Bounded_side operator()(const C& c, const T& p) const + { + Bounded_side s = c.bounded_side(p); + return s; + } +}; + + +template +struct CG_circle_center { + T operator()(const C& c) const + { return c.center(); } +}; + + +template +struct CG_create_circle_ppp { + C operator()(const T& p1,const T& p2,const T& p3) const + { return C(p1,p2,p3); } +}; + +template +struct CG_create_segment_pp { + C operator()(const T& p1,const T& p2) const + { return C(p1,p2); } +}; + +template +struct CG_create_line_pp { + C operator()(const T& p1,const T& p2) const + { return C(p1,p2); } +}; + + +template +class point_set_traits_2 { + public: + typedef typename T::FT FT; + typedef Point_2 Point; + typedef Circle_2 Circle; + typedef Segment_2 Segment; + typedef Line_2 Line; + + typedef CG_Lex_xy Compare_xy_2; + typedef CG_compare_dist Compare_dist_2; + typedef CG_orientation Orientation; + typedef CG_side_of_circle Side_of_oriented_circle_2; + typedef CG_side_of_halfspace Side_of_halfspace_2; + typedef CG_segment_contains Segment_has_on_2; + typedef CG_sqr_dist Squared_distance; + typedef CG_line_sqr_dist Squared_distance_to_line; + typedef CG_circle_ptori Circle_bounded_side_2; + typedef CG_circle_center Circle_center_2; + + typedef CG_create_circle_ppp Construct_circle_2; + typedef CG_create_segment_pp Construct_segment_2; + typedef CG_create_line_pp Construct_line_2; + + Orientation get_orientation_object() const + { return Orientation(); } + + Side_of_oriented_circle_2 get_side_of_oriented_circle_2_object() const + { return Side_of_oriented_circle_2(); } + + Side_of_halfspace_2 get_side_of_halfspace_2_object() const + { return Side_of_halfspace_2(); } + + Segment_has_on_2 get_segment_has_on_2_object() const + { return Segment_has_on_2(); } + + Squared_distance get_squared_distance_object() const + { return Squared_distance(); } + + Squared_distance_to_line get_squared_distance_to_line_object() const + { return Squared_distance_to_line(); } + + Circle_bounded_side_2 get_circle_bounded_side_2_object() const + { return Circle_bounded_side_2(); } + + Circle_center_2 get_circle_center_2_object() const + { return Circle_center_2(); } + + Construct_circle_2 get_construct_circle_2_object() const + { return Construct_circle_2(); } + + Construct_segment_2 get_construct_segment_2_object() const + { return Construct_segment_2(); } + + Construct_line_2 get_construct_line_2_object() const + { return Construct_line_2(); } + + + point_set_traits_2() { } +}; + +CGAL_END_NAMESPACE + + +#if LEDA_ROOT_INCL_ID == 400898 +#undef LEDA_ROOT_INCL_ID +#include +#endif + +#endif diff --git a/Packages/Point_set_2/maintainer b/Packages/Point_set_2/maintainer new file mode 100644 index 00000000000..5ceaaa5d811 --- /dev/null +++ b/Packages/Point_set_2/maintainer @@ -0,0 +1 @@ +Matthias Baesken diff --git a/Packages/Point_set_2/test/Point_set_2/cgal_test b/Packages/Point_set_2/test/Point_set_2/cgal_test new file mode 100755 index 00000000000..6ae674f6280 --- /dev/null +++ b/Packages/Point_set_2/test/Point_set_2/cgal_test @@ -0,0 +1,67 @@ +#! /bin/sh + +# This is a script for the CGAL test suite. Such a script must obey +# the following rules: +# +# - the name of the script is cgal_test +# - for every target two one line messages are written to the file 'error.txt' +# the first one indicates if the compilation was successful +# the second one indicates if the execution was successful +# if one of the two was not successful, the line should start with 'ERROR:' +# - running the script should not require any user interaction +# - the script should clean up object files and executables + +ERRORFILE=error.txt + +#---------------------------------------------------------------------# +# compile_and_run +#---------------------------------------------------------------------# + +compile_and_run() +{ + echo "Compiling $1 ... " + if eval 'make CGAL_MAKEFILE=$CGAL_MAKEFILE \ + TESTSUITE_CXXFLAGS="$TESTSUITE_CXXFLAGS" \ + TESTSUITE_LDFLAGS="$TESTSUITE_LDFLAGS" $1' ; then + echo " compilation of $1 succeeded" >> $ERRORFILE + else + echo " ERROR: compilation of $1 failed" >> $ERRORFILE + fi + + if [ -f $1 ] ; then + OUTPUTFILE=ProgramOutput.$1.$PLATFORM + /bin/rm -f $OUTPUTFILE + COMMAND="./$1" + if [ -f $1.cmd ] ; then + COMMAND="$COMMAND '`cat $1.cmd`'" + fi + if [ -f $1.cin ] ; then + COMMAND="echo '`cat $1.cin`' | $COMMAND" + fi + echo "Executing $1 ... " + echo + if eval 2>&1 $COMMAND > $OUTPUTFILE ; then + echo " execution of $1 succeeded" >> $ERRORFILE + else + echo " ERROR: execution of $1 failed" >> $ERRORFILE + fi + else + echo " ERROR: could not execute $1" >> $ERRORFILE + fi + + eval "2>&1 make CGAL_MAKEFILE=$CGAL_MAKEFILE clean > /dev/null " +} + +#---------------------------------------------------------------------# +# remove the previous error file +#---------------------------------------------------------------------# + +/bin/rm -f $ERRORFILE +touch $ERRORFILE + +#---------------------------------------------------------------------# +# compile and run the tests +#---------------------------------------------------------------------# + +compile_and_run range_search +compile_and_run nearest_nb1 diff --git a/Packages/Point_set_2/test/Point_set_2/makefile b/Packages/Point_set_2/test/Point_set_2/makefile new file mode 100644 index 00000000000..23a25e2e85a --- /dev/null +++ b/Packages/Point_set_2/test/Point_set_2/makefile @@ -0,0 +1,54 @@ +# This is the makefile for compiling the CGAL Kernel test. + +#---------------------------------------------------------------------# +# include platform specific settings +#---------------------------------------------------------------------# +# Choose the right include file from the /make directory. + +include $(CGAL_MAKEFILE) + +#---------------------------------------------------------------------# +# compiler flags +#---------------------------------------------------------------------# + +CXXFLAGS = \ + $(TESTSUITE_CXXFLAGS) \ + -DCGAL_CH_CHECK_EXPENSIVE \ + $(CGAL_CXXFLAGS) \ + $(EXTRA_FLAGS) + + +#---------------------------------------------------------------------# +# linker flags +#---------------------------------------------------------------------# +LIBPATH = \ + $(TESTSUITE_LIBPATH) \ + $(CGAL_LIBPATH) + +LDFLAGS = \ + $(TESTSUITE_LDFLAGS) \ + $(CGAL_LDFLAGS) + +#---------------------------------------------------------------------# +# target entries +#---------------------------------------------------------------------# + +all: \ + range_search \ + nearest_nb1 + +range_search$(EXE_EXT) : range_search$(OBJ_EXT) + $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)range_search range_search$(OBJ_EXT) $(LDFLAGS) + +nearest_nb1$(EXE_EXT) : nearest_nb1$(OBJ_EXT) + $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)nearest_nb1 nearest_nb1$(OBJ_EXT) $(LDFLAGS) + +clean: nearest_nb1.clean range_search.clean + +#---------------------------------------------------------------------# +# suffix rules +#---------------------------------------------------------------------# + +.C$(OBJ_EXT): + $(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $< + diff --git a/Packages/Point_set_2/test/Point_set_2/nearest_nb1.C b/Packages/Point_set_2/test/Point_set_2/nearest_nb1.C new file mode 100644 index 00000000000..07b6558fc02 --- /dev/null +++ b/Packages/Point_set_2/test/Point_set_2/nearest_nb1.C @@ -0,0 +1,137 @@ +#include + +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 400) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + + +#include + +#include +#include + +#include +#include + +using namespace CGAL; + +typedef Cartesian REP; +typedef point_set_traits_2 TRAITS; +typedef Point_set_2::Edge Edge; +typedef Point_set_2::Vertex Vertex; + +Point_set_2 PSet; + +Point_2 ar1[5]; + +int check1(std::list L) +{ + std::cout << "check 1!\n"; + if (L.size() != 5) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar1[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int main() +{ + std::list > Lr; + + int w1,w2; + + Point_2 p1(12,14,1); + Point_2 p2(-12,14,1); + Point_2 p3(2,11,1); + Point_2 p4(5,6,1); + Point_2 p5(67,38,10); + Point_2 p6(11,20,1); + Point_2 p7(-5,6,1); + Point_2 p8(12,0,1); + Point_2 p9(4,31,1); + Point_2 p10(-10,-10,1); + + Lr.push_back(p1); Lr.push_back(p2); Lr.push_back(p3); + Lr.push_back(p4); Lr.push_back(p5); Lr.push_back(p6); + Lr.push_back(p7); Lr.push_back(p8); Lr.push_back(p9); + Lr.push_back(p10); + + PSet.init(Lr.begin(),Lr.end()); + + // init + ar1[0]=p4; ar1[1]=p5; ar1[2]=p3; ar1[3]=p7; ar1[4]=p8; + + Point_2 actual(30,45,10); + + // nearest neighbor ... + Vertex v = PSet.nearest_neighbor(actual); + std::cout << "Nearest neighbor:" << PSet.pos(v) << "\n"; + + if (PSet.pos(v) == p4) w1=0; else w1=1; + + // k nearest neighbors ... + std::list L; + std::list::const_iterator it; + + PSet.nearest_neighbors(actual,5,std::back_inserter(L)); + std::cout << "actual point: " << actual << "\n"; + + for (it=L.begin();it != L.end(); it++) + std::cout << PSet.pos(*it) << "\n"; + + w2=check1(L); + + // construction ... + Point_set_2 PSet2; + Point_set_2 PSet3(Lr.begin(),Lr.end()); + Point_set_2 PSet4(Lr); + + // init ... + PSet2.init(Lr); + + //get points/segments ... + std::list > ptlist; + std::list > seglist; + + PSet3.points(std::back_inserter(ptlist)); + PSet3.segments(std::back_inserter(seglist)); + + std::cout << PSet3.is_empty() << "\n"; + PSet3.clear(); + + Edge eakt = PSet4.locate(actual); + + std::cout << PSet4.seg(eakt) << "\n"; + + PSet4.lookup(actual); + + // insert/ delete + Vertex vnew = PSet4.insert(actual); + + std::cout << PSet4.pos(vnew) << "\n"; + + PSet4.del(actual); + + Edge he = PSet4.get_hull_edge(); + + std::cout << PSet4.is_diagram_edge(he) << "\n"; + std::cout << PSet4.is_hull_edge(he) << "\n"; + + std::cout << PSet4.dim() << "\n"; + + if (w1==0 && w2==0) return 0; + else return 1; +} + +#endif diff --git a/Packages/Point_set_2/test/Point_set_2/range_search.C b/Packages/Point_set_2/test/Point_set_2/range_search.C new file mode 100644 index 00000000000..b92c43624bb --- /dev/null +++ b/Packages/Point_set_2/test/Point_set_2/range_search.C @@ -0,0 +1,154 @@ +#include + +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 400) +#include + +int main(int argc, char *argv[]) +{ + std::cout << "No LEDA installed!\n"; + return 0; +} +#else + +#include + +#include +#include + +#include +#include + +using namespace CGAL; +using namespace std; + +typedef Cartesian REP; +typedef point_set_traits_2 TRAITS; +typedef Point_set_2::Edge Edge; +typedef Point_set_2::Vertex Vertex; + +Point_set_2 PSet; + +Point_2 ar1[6]; +Point_2 ar2[3]; +Point_2 ar3[3]; + +int check1(std::list L) +{ + cout << "check 1!\n"; + if (L.size() != 6) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar1[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int check2(std::list L) +{ + cout << "check 2!\n"; + if (L.size() != 3) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar2[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int check3(std::list L) +{ + cout << "check 3!\n"; + if (L.size() != 3) return 1; + std::list::const_iterator it = L.begin(); + int i=0; + int w=0; + + for(; it != L.end();it++){ + if (ar3[i] != PSet.pos(*it)) w=1; + i++; + } + return w; +} + +int main() +{ + Point_2 pnew(120,62,10); + + int w1,w2,w3; + + std::list > Lr; + + Point_2 p1(12,14,1); + Point_2 p2(-12,14,1); + Point_2 p3(2,11,1); + Point_2 p4(5,6,1); + Point_2 p5(67,38,10); + Point_2 p6(11,20,1); + Point_2 p7(-5,6,1); + Point_2 p8(12,0,1); + Point_2 p9(4,31,1); + Point_2 p10(-10,-10,1); + + // init + ar1[0]=p1; ar1[1]=p6; ar1[2]=p3; ar1[3]=p4; ar1[4]=p5; ar1[5]=pnew; + ar2[0]=p2; ar2[1]=p3; ar2[2]=p1; + ar3[0]=p7; ar3[1]=p10; ar3[2]=p3; + + Lr.push_back(p1); Lr.push_back(p2); Lr.push_back(p3); + Lr.push_back(p4); Lr.push_back(p5); Lr.push_back(p6); + Lr.push_back(p7); Lr.push_back(p8); Lr.push_back(p9); + Lr.push_back(p10); + + PSet.init(Lr.begin(),Lr.end()); + + cout << "insert!\n"; cout.flush(); + PSet.insert(pnew); + + + cout << "range search for circle !\n"; + Circle_2 rc(p5,p6); + + std::list LV; + PSet.range_search(rc,back_inserter(LV)); + + std::list::const_iterator it; + for (it=LV.begin();it != LV.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w1 = check1(LV); + + cout << "range search for triangle !\n"; + + LV.clear(); + PSet.range_search(p1,p2,p3,back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w2 = check2(LV); + LV.clear(); + + cout << "range search for iso rectangle !\n"; + Point_2 pt1=p10; // lower left + Point_2 pt3=p3; // upper right + + Point_2 pt2 = Point_2(pt3.x(),pt1.y()); + Point_2 pt4 = Point_2(pt1.x(),pt3.y()); + + PSet.range_search(pt1,pt2,pt3,pt4,back_inserter(LV)); + for (it=LV.begin();it != LV.end(); it++) + cout << PSet.pos(*it) << "\n"; + + w3 = check3(LV); + + if (w1==0 && w2==0 && w3==0) return 0; + else return 1; +} + +#endif diff --git a/Packages/Point_set_2/version b/Packages/Point_set_2/version new file mode 100644 index 00000000000..35123ea33ba --- /dev/null +++ b/Packages/Point_set_2/version @@ -0,0 +1,2 @@ +1.2.4 (14 September 2000) +maintainer: Matthias Baesken diff --git a/Packages/Timer/changes.txt b/Packages/Timer/changes.txt new file mode 100644 index 00000000000..b9dc61585ec --- /dev/null +++ b/Packages/Timer/changes.txt @@ -0,0 +1,31 @@ +Timer Package: Release changes: +--------------------------------------------------------------------- +1.8 (11 August 2000) + change to ccRefName in the manual + +1.7 (14 April 2000) + changed the manual a bit + +1.6 (1 Feb 2000) + some changes for Borland C++ + Real_timer.h reorganized a bit + +1.5 CGAL_CLIB_STD added at a few places + +1.4 (20 Sept 1999) + endl 's removed + +1.3 (17 Sept 1999) + added std:: to cerr + +1.2 (13 Sept 1999) + Changes for Visual C++; uses _ftime on this platform for Real_timer + +1.1 (05 Mar 1999) + + Standard headers, std namespace and CGAL namespace. + This new package is spawned from the old Support_LK package + 1.18 (07 Oct 1998). Timer.h and Real_timer.h are here separated + in their own package to reflect that they have their own chapter + in the manual. + diff --git a/Packages/Timer/description.txt b/Packages/Timer/description.txt new file mode 100644 index 00000000000..e274c93d20e --- /dev/null +++ b/Packages/Timer/description.txt @@ -0,0 +1 @@ +Timer for user and real-time. diff --git a/Packages/Timer/doc_tex/Timer/cgal.bib b/Packages/Timer/doc_tex/Timer/cgal.bib new file mode 100644 index 00000000000..3e210afc47c --- /dev/null +++ b/Packages/Timer/doc_tex/Timer/cgal.bib @@ -0,0 +1,1061 @@ +% ------------------------------------------------------------------------ +% cgal.bib +% -------- +% BiBTeX references used in the CGAL project which are not in geombib. +% geombib is available from: +% +% file://ftp.cs.usask.ca/pub/geometry/geombib.tar.Z +% +% 29.04.1997 Lutz Kettner kettner_inf.ethz.ch +% +% annote entry might contain "recommended C++ reading" or +% "recommended OO reading". +% +% ------------------------------------------------------------------------ + + +% Common abbreviations for publishers, journals, ... +% -------------------------------------------------- + +@string{ addison = {Addison-Wesley}} +@string{ mcgraw = {McGraw-Hill}} +@string{ academic = {Academic Press}} +@string{ springer = {Springer Verlag}} +@string{ oldenbourg = {Oldenbourg Verlag, M\"unchen, Wien}} +@string{ gruyter = {Walter de Gruyter, Berlin}} +@string{ elsevier = {Elsevier Science Publishers, Amsterdam, The + Netherlands}} +@string{ acm = {ACM Press}} +@string{ wiley = {John Wiley \& Sons, New York}} +@string{ cambridge = {Cambridge University Press}} +@string{ kaufmann = {Morgan Kaufmann}} +@string{ kluwer = {Kluwer Academic Publishers Group}} + +% Alphabetically sorted list of references. +% ----------------------------------------- + +@incollection{ a-cgs-97 + ,author = "N. Amenta" + ,title = "Computational Geometry Software" + ,booktitle = "Handbook of Discrete and Computational Geometry" + ,editors = "J. Goodman and J. O'Rourke" + ,publisher = "CRC Press" + ,year = "1997" + ,pages = "951--960" + ,update = "98.01 schirra" +} + +@inproceedings{ a-nqimr-67 + ,author = {Arthur Appel} + ,title = {The Notion of Quantitive Invisibility and the + Machine Rendering of Solids} + ,booktitle = {Proc. ACM National Conf.} + ,year = 1967 + ,pages = {387--393} + ,annote = {Basis for the contour edge idea in hidden surface + removal.} + ,update = "97.04 kettner" +} + +@book{ bn-sec++-94 + ,author = "J. J. Barton and L. R. Nackman" + ,title = "Scientific and Engineering {C{\tt ++}}" + ,publisher = "Addison-Wesley, Reading, MA" + ,year = "1997" + ,update = "98.01 schirra" +} + +@inproceedings{ bfh-mgedm-95 + ,author = {Heinzgerd Bendels and Dieter W. Fellner and Sven + Havemann} + ,title = {Modellierung der Grundlagen: Erweiterbare + Datenstrukturen zur Modellierung und Visualisierung + polygonaler Welten} + ,booktitle = {Modeling -- Virtual Worlds -- Distributed Graphics} + ,year = 1995 + ,editor = {D. W. Fellner} + ,pages = {149--157} + ,address = {Bad Honnef / Bonn} + ,month = {27.--28. November} + ,annote = {A reference for the halfedge data structure and + Euler operators (preserving the topological type).} + ,update = "97.04 kettner" +} + +@misc{ bpp-vrml-95 + ,author = {Gavin Bell and Anthony Parisi and Mark Pesce} + ,title = {VRML The Virtual Reality Modeling Language: + Version 1.0 Specification} + ,howpublished = {\path|http://www.vrml.org/|} + ,month = {May 26} + ,year = 1995 + ,note = {Third Draft} + ,update = "97.04 kettner" +} + +@incollection{ bv-sbc-96 + ,author = "G. Booch and M. Vilot" + ,title = "Simplifying the Booch Components" + ,booktitle = "{\CC\ }Gems" + ,publisher = "SIGS publications" + ,editor = "Lippman, S." + ,year = "1996" + ,pages = "59--89" + ,update = "98.01 schirra" +} + +@incollection{ cgal-nt-97 + ,author = {{CGAL} consortium} + ,title = {Number Types} + ,booktitle = {{CGAL} Reference Manual. {P}art 3: {S}upport Library} + ,editor = {Andreas Fabri and Stefan Schirra and + Remco Veltkamp} + ,year = 1997 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "98.01 giezeman" +} + +@misc{ + ,author = {{CGAL} consortium} + ,title = {{CGAL} Workpackage 4, Report 2} + ,howpublished = {\path|http://www.cs.ruu.nl/CGAL|} + ,month = {fall} + ,year = 1997 + ,update = "98.01 kettner" +} + +@misc{ + ,author = {{CGAL} consortium} + ,title = {{CGAL} Workpackage 4, Report 1} + ,howpublished = {\path|http://www.cs.ruu.nl/CGAL|} + ,month = apr + ,year = 1997 + ,update = "98.01 kettner" +} + +@inproceedings{ cvmtwabw-se-96 + ,author = {Jonathan Cohen and Amitabh Varshney and Dinesh + Manocha and Greg Turk and Hans Weber and Pankaj + Agarwal and Frederick Brooks and William Wright} + ,title = {Simplification Envelopes} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '96)" + ,volume = 30 + ,year = 1996 + ,pages = {119--128} + ,note = {Examples and code in + \path|http://www.cs.unc.edu/~geom/envelope.html|} + ,update = "97.08 kettner" +} + +@inproceedings{ cl-vmbcm-96 + ,author = {Brian Curless and Marc Levoy} + ,title = {A Volumetric Method for Building Complex + Models from Range Images} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '96)" + ,volume = 30 + ,year = 1996 + ,pages = {303--312} + ,update = "97.08 kettner" +} + +@misc{ c-wpdpi-95 + ,key = {C++AnsiDraft} + ,title = "Working Paper for Draft Proposed International + Standard for Information Systems -- Programming + Language {C{\tt ++}}" + ,howpublished = {ANSI X3, Information Processing Systems} + ,month = apr + ,year = 1995 + ,note = {\path|http://www.cygnus.com/misc/wp/|} + ,update = "97.04 kettner" +} + +@misc{ c-wpdpi-96 + ,key = {{C}{\tt ++}} + ,title = "Working Paper for Draft Proposed International + Standard for Information Systems -- Programming + Language {C{\tt ++}}" + ,howpublished = {Doc.~No.~X3J16/96 - 0225 - WG21/N1043} + ,month = Dec + ,year = 1996 + ,note = {\path|http://www.maths.warwick.ac.uk/c++/pub/|} + ,update = "97.04 kettner, 98.02 schirra" +} + +@misc{ c-isplc-98 + ,key = {{C}{\tt ++}} + ,title = "International Standard ISO/IEC 14882: + Programming languages -- {C{\tt ++}}" + ,howpublished = {American National Standards Institute, 11 West 42nd + Street, New York 10036} + ,year = 1998 + ,mynote = {\path|http://webstore.ansi.org/|} + ,update = "99.02 kettner" +} + +@misc{ c-isplc-98 + ,key = {{C}{\tt ++}} + ,title = "International Standard ISO/IEC 14882: + Programming languages -- {C{\tt ++}}" + ,howpublished = {American National Standards Institute, 11 West 42nd + Street, New York 10036} + ,year = 1998 + ,mynote = {\path|http://webstore.ansi.org/|} + ,update = "98.11 kettner" +} + +@misc{ OLD-c-wpdpi-96 + ,key = {C++AnsiDraft} + ,title = "Working Paper for Draft Proposed International + Standard for Information Systems -- Programming + Language {C{\tt ++}}" + ,howpublished = {ANSI X3, Information Processing Systems} + ,month = dec + ,year = 1996 + ,note = {\path|http://www.maths.warwick.ac.uk/c++/pub/|} + ,update = "97.04 kettner" +} + +@inproceedings{ eddhls-maam-95 + ,author = {Matthias Eck and Tony DeRose and Tom Duchamp and + Hugues Hoppe and Michael Lounsbery and Werner Stuetzle} + ,title = {Multiresolution Analysis of Arbitrary Meshes} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '95)" + ,volume = 29 + ,year = 1995 + ,pages = {173--182} + ,note = {Examples in + \path|file://ftp.cs.washington.edu/pub/graphics|} + ,update = "97.08 kettner" +} + +@inproceedings{ fgkss-ckbgc-96 + ,author = {Andreas Fabri and Geert-Jan Giezeman and Lutz + Kettner and Stefan Schirra and Sven Sch{\"o}nherr} + ,title = {The {CGAL} Kernel: A Basis for Geometric Computation} + ,booktitle = {ACM Workshop on Applied Computational Geometry} + ,editor = {M. C. Lin and D. Manocha} + ,address = {Philadelphia, Pennsylvenia} + ,month = {May, 27--28} + ,year = 1996 + ,pages = {191--202} + ,note = {Springer Lecture Notes in Computer Science 1148} + ,update = "97.04 kettner" +} + +@book{ f-sec-85 + ,author = {Richard Fairley} + ,title = {Software Engineering Concepts} + ,publisher = {McGraw-Hill} + ,year = 1985 + ,series = {McGraw-Hill Series in Software Engineering and Technology} + ,annote = {recommended software engineering reading. + Topics from pre-object-oriented software engineering.} + ,update = "98.01 kettner" +} + +@book{ ghjv-dpero-95 + ,author = {E. Gamma and R. Helm and R. Johnson and J. Vlissides} + ,title = {Design Patterns -- Elements of Reusable + Object-Oriented Software} + ,publisher = addison + ,year = 1995 + ,annote = {recommended OO reading.} + ,update = "97.04 kettner" +} + +@article{ g-ieva-85 + ,author = {Ronald N. Goldman} + ,title = {Illicit Expressions in Vector Algebra} + ,journal = {ACM Transaction on Graphics} + ,year = 1985 + ,volume = 4 + ,number = 3 + ,month = jul + ,pages = {223--243} + ,update = "98.01 kettner" +} + +@book{ hw-vrml2h-96 + ,author = {Jed Hartman and Josie Wernecke} + ,title = {The {VRML} 2.0 Handbook: Building Moving Worlds on the + Web} + ,publisher = addison + ,year = 1996 + ,annote = {The VRML 2.0 Introduction and Reference by + Silicon Graphics.} + ,update = "98.02 kettner" +} + +@misc{ h-97 + ,author = {Michael Hoffmann} + ,year = 1997 + ,note = {personal communication} + ,update = "98.01 kettner" +} + +@inproceedings{ hddms-srup-92 + ,author = {Hugues Hoppe and Tony DeRose and Tom Duchamp and + John McDonald and Werner Stuetzle} + ,title = {Surface Reconstruction from Unorganized Points} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '90)" + ,volume = 26 + ,year = 1992 + ,pages = {71--77} + ,update = "97.08 kettner" +} + +@inproceedings{ hddms-mo-93 + ,author = {Hugues Hoppe and Tony DeRose and Tom Duchamp and + John McDonald and Werner Stuetzle} + ,title = {Mesh Optimization} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '93)" + ,volume = 27 + ,year = 1993 + ,pages = {19--26} + ,note = {Examples and code in + \path|file://ftp.cs.washington.edu/pub/graphics|} + ,update = "97.08 kettner" +} + +@phdthesis{ h-srup-94 + ,author = {Hugues Hoppe} + ,title = {Surface reconstruction from unorganized points} + ,school = {University of Washington} + ,year = 1994 + ,update = "97.08 kettner" +} + +@inproceedings{ hddhjmss-pssr-94 + ,author = {Hugues Hoppe and Tony DeRose and Tom Duchamp and + Mark Halstaed and Hubert Jin and John McDonald and + Jean Schweitzer and Werner Stuetzle} + ,title = {Piecewise Smooth Surface Reconstruction} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '94)" + ,volume = 28 + ,year = 1994 + ,pages = {295--302} + ,note = {Examples and code in + \path|file://ftp.cs.washington.edu/pub/graphics|} + ,update = "97.08 kettner" +} + +@inproceedings{ h-pm-96 + ,author = {Hugues Hoppe} + ,title = {Progressive Meshes} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '96)" + ,volume = 30 + ,year = 1996 + ,pages = {99--108} + ,update = "97.08 kettner" +} + +@incollection{ k-dat-96 + ,author = "Keffer, T." + ,title = "The Design and Architecture of {T}ools.h{\tt ++}" + ,booktitle = "{C{\tt ++}}~Gems" + ,publisher = "SIGS publications" + ,editor = "Lippman, S." + ,year = "1996" + ,pages = "43--57" + ,update = "98.01 schirra" +} + +@incollection{ kw-ceapp-97 + ,author = {Lutz Kettner and Emo Welzl} + ,title = {Contour Edge Analysis for Polyhedron Projections} + ,booktitle = {Geometric Modeling: Theory and Practice} + ,year = 1997 + ,pages = {379--394} + ,publisher = {Springer Verlag} + ,editor = {Wolfgang Strasser and Reinhard Klein and Rene Rau} + ,update = "97.04 kettner, 97.08 kettner" +} + +@incollection{ kw-osepg-98 + ,author = {Lutz Kettner and Emo Welzl} + ,title = {One Sided Error Predicates in Geometric Computing} + ,booktitle = {Proc. 15th IFIP World Computer Congress, + Fundamentals - Foundations of Computer Science} + ,year = 1998 + ,pages = {13--26} + ,editor = {Kurt Mehlhorn} + ,update = "98.08 kettner" +} + +@inproceedings{ k-ddsps-98 + ,author = {Lutz Kettner} + ,title = {Designing a Data Structure for Polyhedral Surfaces} + ,booktitle = {Proc. 14th Annu. ACM Sympos. Comput. Geom.} + ,year = 1998 + ,pages = {146--154} + ,abstract = { + Design solutions for a program library are presented for combinatorial + data structures in computational geometry, such as planar maps and + polyhedral surfaces. Design issues considered are genericity, + flexibility, time and space efficiency, and ease-of-use. We focus on + topological aspects of polyhedral surfaces. Edge-based representations + for polyhedrons are evaluated with respect to the design goals. A + design for polyhedral surfaces in a halfedge data structure is + developed following the generic programming paradigm known from the + Standard Template Library STL for C++. Connections are shown to planar + maps and face-based structures managing holes in facets} +} + +@techreport{ k-ddsps-97 + ,author = {Lutz Kettner} + ,title = {Designing a Data Structure for Polyhedral Surfaces} + ,institution = {Department Informatik, ETH Z{\"u}rich} + ,year = 1997 + ,type = {Technical Report} + ,number = {\#278} + ,address = {Switzerland} + ,pages = {27} + ,month = dec + ,abstract = { + Design solutions for a program library are presented for combinatorial + data structures in computational geometry, such as planar maps and + polyhedral surfaces. Design issues considered are genericity, + flexibility, time and space efficiency, and ease-of-use. We focus on + topological aspects of polyhedral surfaces. Edge-based representations + for polyhedrons are evaluated with respect to the design goals. A + design for polyhedral surfaces in a halfedge data structure is + developed following the generic programming paradigm known from the + Standard Template Library STL for C++. Connections are shown to planar + maps and face-based structures managing holes in facets} + ,update = "98.01 kettner" +} + +@incollection{ k-ps-97 + ,author = {Lutz Kettner} + ,title = {{3D}-Polyhedral Surfaces} + ,booktitle = {{CGAL} Reference Manual. Part 2: Basic Library} + ,editor = {Andreas Fabri and Stefan Schirra and Remco Veltkamp} + ,year = 1997 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "97.12 kettner" +} + +@incollection{ k-c-97 + ,author = {Lutz Kettner} + ,title = {Circulators} + ,booktitle = {{CGAL} Reference Manual. Part 3: Support Library} + ,editor = {Andreas Fabri and Stefan Schirra and Remco Veltkamp} + ,year = 1997 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "97.12 kettner" +} + +@manual{ kl-cssd-94 + ,title = {The {CWEB} System of Structured Documentation} + ,author = {Donald E. Knuth and Silvio Levy} + ,edition = {Version 3.0} + ,year = 1994 + ,update = "98.01 kettner" +} + +@article{ k-lp-84 + ,author = {Donald E. Knuth} + ,title = {Literate Programming} + ,journal = {The Computer Journal} + ,year = 1984 + ,volume = 27 + ,number = 2 + ,pages = {97--111} + ,update = "98.01 kettner" +} + +@article{ kl-isc++l-96 + ,author = "K. Kreft and A. Langer" + ,title = "Iterators in the Standard {\CC\ }Library" + ,journal = "{C{\tt ++}}~Report" + ,volume = "8" + ,number = "10" + ,month = "Nov.-Dec." + ,year = "1996" + ,pages = "27--32" + ,update = "98.01 schirra" +} + +@techreport{ kw-dat-96 + ,author = {Dietmar K{\"u}hl and Karsten Weihe} + ,title = {Data Access Templates} + ,institution = {Universit\"at Konstanz, Germany} + ,year = 1996 + ,type = {Konstanzer Schriften in Mathematik und Informatik} + ,number = {Nr. 9} + ,month = may + ,note = {\path|http://www.informatik.uni-konstanz.de/Schriften|} + ,annote = {recommended C++ reading.} + ,update = "97.04 kettner" +} + +@book{ l-lscsd-96 + ,author = {John Lakos} + ,title = {Large Scale {C{\tt ++}} Software Design} + ,publisher = addison + ,year = 1996 + ,annote = {recommended OO reading.} + ,update = "97.04 kettner" +} + +@inproceedings{ l-vgasa-96 + ,author = "D. T. Lee" + ,title = "Visualizing Geometric Algorithms -- State of the Art" + ,editor = "M. C. Lin and D. Manocha" + ,booktitle = "Applied Computational Geometry (Proc. WACG~'96)" + ,series = "Lecture Notes Comput. Sci." + ,volume = 1148 + ,publisher = "Springer-Verlag" + ,year = 1996 + ,pages = "45--50" + ,update = "98.01 schirra" +} + +@book{ l-icom-96 + ,author = {Stanley B. Lippman} + ,title = {Inside the {C{\tt ++}} Object Model} + ,publisher = addison + ,year = 1996 + ,annote = {Insides into C++ compiler implementations. + Performance issues of various C++ features. } + ,update = "97.04 kettner" +} + +@book{ m-wsc-93 + ,author = {Steve Maguire} + ,title = {Writing Solid Code} + ,publisher = {Microsoft Press} + ,year = 1993 + ,annote = {Microsoft's techniques for developing bug-free C programs} + ,update = "98.01 schirra" +} + +@inproceedings{ m-pppd-96 + ,author = "Kurt Mehlhorn" + ,title = "Position Paper for Panel Discussion" + ,editor = "M. C. Lin and D. Manocha" + ,booktitle = "Applied Computational Geometry (Proc. WACG~'96)" + ,series = "Lecture Notes Comput. Sci." + ,volume = 1148 + ,publisher = "Springer-Verlag" + ,year = 1996 + ,pages = "51--52" + ,update = "98.01 schirra" +} + +@manual{ mnu-lum-97 + ,author = {Mehlhorn, K. and N\"aher, S. and Uhrig, C.} + ,title = {The {LEDA} {U}ser {M}anual, {V}ersion 3.5} + ,organization = {Max-Planck-Insitut f\"ur Informatik} + ,address = {66123 Saarbr\"ucken, Germany} + ,year = {1997} + ,note = {\path|http://www.mpi-sb.mpg.de/LEDA/leda.html|} + ,update = "97.12 kettner, 98.02 schirra" +} + +@manual{ OLD-mnu-lum-97 + ,title = {The {LEDA} {U}ser {M}anual, {V}ersion 3.5} + ,author = {Kurt Mehlhorn and Stefan N{\"a}her and Christian Uhrig} + ,organization = {LEDA Software GmbH} + ,address = {66123 Saarbr\"ucken, Germany} + ,year = 1997 + ,update = "97.12 kettner" +} + +@book{ m-ec-92 + ,author = {Scott Meyers} + ,title = "Effective {C{\tt ++}}" + ,publisher = addison + ,year = 1992 + ,annote = {recommended C++ reading. 50 Specific Ways to + Improve Your Programs and Designs} + ,update = "97.04 schönherr" +} + +@book{ m-mec-96 + ,author = {Scott Meyers} + ,title = "More Effective {C{\tt ++}}" + ,publisher = addison + ,year = 1996 + ,annote = {recommended C++ reading. 35 New Ways to + Improve Your Programs and Designs} + ,update = "97.04 schönherr" +} + +@book{ m-cst-93 + ,author = {Robert B. Murray} + ,title = "{C{\tt ++}} Strategies and Tactics" + ,publisher = addison + ,year = 1993 + ,annote = {recommended C++ reading} + ,update = "98.01 schirra" +} + +@article{ m-tnutt-95 + ,author = {Nathan C. Myers} + ,title = {Traits: a New and Useful Template Technique} + ,journal = "{C{\tt ++}}~Report" + ,year = 1995 + ,month = jun + ,annote = {recommended C++ reading. stream traits, iterator + traits, typedef's.} + ,update = "97.04 kettner" +} + +@inproceedings{ ms-gp-89 + ,author = {David R.~Musser and Alexander A.~Stepanov} + ,title = {Generic Programming} + ,booktitle = {1st Intl.\ Joint Conf.\ of ISSAC-88 and AAEC-6} + ,year = 1989 + ,pages = {13--25} + ,publisher = {Springer LNCS 358} +} + +@article{ ms-aogl-94 + ,author = {David R.~Musser and Alexander A.~Stepanov} + ,title = {Algorithm-oriented Generic Libraries} + ,journal = {Software -- Practice and Experience} + ,year = 1994 + ,volume = 24 + ,number = 7 + ,pages = {623--642} + ,month = jul +} + +@book{ ms-strg-96 + ,author = {David R. Musser and Atul Saini} + ,title = "{STL} Tutorial and Reference Guide: + {C{\tt ++}}~Programming with the Standard Template + Library" + ,publisher = addison + ,year = 1996 + ,annote = {recommended C++ reading.} + ,update = "97.04 kettner" +} + +@manual{ nu-leda32-95 + ,title = {The {L}{E}{D}{A} {U}ser {M}anual, {V}ersion {R} 3.2} + ,author = {S.~N{\"a}her and C.~Uhrig} + ,organization = {Max-Planck-Institut f\"ur Informatik} + ,address = {Saarbr\"ucken, Germany} + ,year = 1995 + ,update = "97.04 kettner" +} + +@book{ ndw-opgog-93 + ,author = {Jackie Neider and Tom Davis and Mason Woo} + ,title = {OpenGL Programming Guide: The Official Guide to + Learning OpenGL, Release 1} + ,publisher = addison + ,year = 1993 + ,update = "97.04 kettner" +} + +@inproceedings{ o-dcgal-96 + ,author = {Mark H. Overmars} + ,title = {Designing the Computational Geometry Algorithms + Library {CGAL}} + ,booktitle = {ACM Workshop on Applied Computational Geometry} + ,editor = {M. C. Lin and D. Manocha} + ,address = {Philadelphia, Pennsylvenia} + ,month = {May, 27--28} + ,year = 1996 + ,note = {Lecture Notes in Computer Science 1148} + ,update = "97.04 kettner" +} + +@article{ pc-rdp-86 + ,author = {David L. Parnas and Paul C. Clements} + ,title = {A Rational Design Process: How and Why to Fake It} + ,journal = {IEEE Transactions on Software Engineering} + ,year = 1986 + ,volume = 12 + ,number = 2 + ,pages = {251-257} + ,update = "98.01 kettner" +} + +@manual{ p-gmgv15-94 + ,title = {Geomview Manual: Geomview Version 1.5 for Silicon + Graphics Workstations} + ,author = {Mark Phillips} + ,organization = {The Geometry Center} + ,address = {University of Minnesota} + ,month = oct + ,year = 1994 + ,note = {\path|http://www.geom.umn.edu/software/download/geomview.html|} + ,annote = {Reference for object file format (OFF).} + ,update = "97.04 kettner" +} + +@book{ rbpel-oomd-91 + ,author = {James Rumbaugh and Michael Blaha and William + Premerlani and Frederick Eddy and William Lorenson} + ,title = {Object-Oriented Modeling and Design} + ,publisher = {Prentice Hall} + ,address = {Englewood Cliffs, NJ} + ,year = 1991 + ,annote = {Object and class diagram notation as used in the + book of design patterns ghjv-dpero-95.} + ,update = "97.04 kettner" +} + +@article{ r-lomom-94 + ,author = {James Rumbaugh} + ,title = {The Life of an Object Model: How the Object-Model + Changes During Development} + ,journal = {Journal of Object-Oriented Programming} + ,year = 1994 + ,volume = 7 + ,number = 1 + ,pages = {24--32} + ,month = {March/April} + ,annote = {Object and class diagram notation as used in the + book of design patterns ghjv-dpero-95.} + ,update = "97.04 kettner" +} + +@misc{ s-dcgal-96 + ,author = "S. Schirra" + ,title = "Designing a Computational Geometry Algorithms Library" + ,howpublished = "Lecture Notes for Advanced School on Algorithmic + Foundations of Geographic Information Systems, CISM, + Udine" + ,month = "September 16-20" + ,year = "1996" + ,update = "98.01 schirra" +} + +@techreport{ s-picpc-98 + ,author = {Schirra, Stefan} + ,title = {Parameterized Implementations of Classical Planar + Convex Hull Algorithms and Extreme Point Computations} + ,type = {Research Report} + ,institution = {Max-Planck-Institut f{\"u}r Informatik} + ,address = {Im Stadtwald, D-66123 Saarbr{\"u}cken, Germany} + ,number = {MPI-I-98-1-003} + ,month = {January} + ,year = {1998} + ,issn = {0946-011X} + ,update = "98.01 schirra" +} + +@incollection{s-ixgpe-91a + ,author = "Peter Schorn" + ,title = "Implementing the {XYZ} {GeoBench}: A programming + environment for geometric algorithms" + ,booktitle = "Computational Geometry --- Methods, Algorithms and + Applications: Proc. Internat. Workshop Comput. + Geom. CG '91" + ,series = "Lecture Notes Comput. Sci." + ,volume = 553 + ,publisher = "Springer-Verlag" + ,year = 1991 + ,pages = "187--202" + ,note = {\path|http://wwwjn.inf.ethz.ch/geobench/XYZGeoBench.html|} + ,update = "94.01 rote, 98.01 kettner" +} + +%%\bibitem{schutte} Michael Schutte, Zufaellige Konvexe Mengen, +%% Diplomarbeit Freie Universitaet Berlin, 1996. + +@mastersthesis{ s-zkm-96 + ,author = {Michael Schutte} + ,title = {Zuf{\"a}llige Konvexe Mengen} + ,school = {Freie Universit{\"a}t Berlin} + ,year = 1996 + ,address = {Germany} +} + +@misc{ sgcsi-stlpg-97 + ,author = {{Silicon Graphics Computer Systems{,} Inc.}} + ,title = {Standard Template Library Programmer's Guide} + ,howpublished = {\path|http://www.sgi.com/Technology/STL/|} + ,year = 1997 + ,annote = {Web reference to the STL from SGI. + recommended C++ and STL reference material.} + ,update = "97.12 kettner" +} + +@article{ ss-ablp-91 + ,author = {Lisa M. C. Smith and Mansur H. Samadzadeh} + ,title = {An Annotated Bibliography of Literate Programming} + ,journal = {ACM SIGPLAN Notices} + ,year = 1991 + ,volume = 26 + ,number = 1 + ,pages = {14--20} + ,month = jan + ,update = "98.01 kettner" +} + +@book{ s-cpl-91 + ,author = {Bjarne Stroustrup} + ,title = "The {C{\tt ++}}~Programming Language" + ,publisher = addison + ,year = 1991 + ,edition = {2nd} + ,annote = {recommended C++ reading.} + ,update = "97.04 kettner" +} + +@book{ s-cpl-97 + ,author = {Bjarne Stroustrup} + ,title = "The {C{\tt ++}}~Programming Language" + ,publisher = addison + ,year = 1997 + ,edition = {3rd} + ,annote = {recommended C++ reading.} + ,update = "97.12 kettner" +} + +@misc{ sl-stl-95 + ,author = {Alexander Stepanov and Meng Lee} + ,title = {The Standard Template Library} + ,howpublished = {\path|http://www.cs.rpi.edu/~musser/doc.ps|} + ,month = oct + ,year = 1995 + ,annote = {recommended C++ reading. Short introduction to the + STL. Precise requirements for the iterators and + containers. Explanation of iterator tags (outdated).} + ,update = "97.04 kettner" +} + +@article{ v-tm-95 + ,author = {Todd Veldhuizen} + ,title = {Template Metaprograms} + ,journal = "{C{\tt ++}}~Report" + ,year = 1995 + ,month = may + ,pages = {36--43} + ,annote = {Prime numbers at compiler time, C++ programs at + compile time, control structures, local variables.} + ,update = "98.01 kettner" +} + +@article{ v-et-95 + ,author = {Todd Veldhuizen} + ,title = {Expressions Templates} + ,journal = "{C{\tt ++}}~Report" + ,year = 1995 + ,month = jun + ,pages = {26--31} + ,annote = {Inlining vector expressions and parameter passing + of expressions at compile time. Template Metaprograms.} + ,update = "98.01 kettner" +} + +@article{ v-lactm-96 + ,author = {Todd Veldhuizen and Kumaraswamy Ponnambalam} + ,title = {Linear Algebra with {C{\tt ++}} Template Metaprograms} + ,journal = {Dr. Dobb's Journal} + ,year = 1996 + ,month = aug + ,annote = {Vector operations without temporary variables.} + ,update = "98.01 kettner" +} + +@inproceedings{ v-gpc-97 + ,author = "R. C. Veltkamp" + ,title = "Generic Programming in {CGAL}, the Computational + Geometry Algorithms Library" + ,booktitle = "Proceedings of the 6th Eurographics Workshop on + Programming Paradigms in Graphics" + ,year = "1997" + ,update = "98.01 schirra" +} + +@misc{ vrmls-96 + ,key = {VRML2} + ,title = {The Virtual Reality Modeling Language Specification: + Version 2.0, {ISO}/{IEC} {CD} 14772} + ,howpublished = {\path|http://www.vrml.org/|} + ,month = {August 4} + ,year = 1996 + ,update = "98.01 kettner" +} + +@incollection{ w-fvt-90 + ,author = {Bob Wallis} + ,title = {Forms, Vectors, and Transforms} + ,booktitle = {Graphics Gems} + ,publisher = academic + ,year = 1990 + ,editor = {Andrew S. Glassner} + ,pages = {533-538} + ,annote = {Normal vectors under affine transformations, + tensor algebra and differential geometry, triangular + interpolants, subdeviding a parametric polynomial + curve} + ,update = "98.01 kettner" +} + +@article{ w-ebdss-85 + ,author = {Kevin Weiler} + ,title = {Edge-Based Data Structures for Solid Modeling in + Curved-Surface Environments} + ,journal = {IEEE Computer Graphics and Application} + ,year = 1985 + ,volume = 5 + ,number = 1 + ,pages = {21--40} + ,month = jan + ,annote = {Good halfedge reference. reference from Foley90} + ,update = "98.01 kettner" +} + +@book{ w-impoo-94 + ,author = {Josie Wernicke} + ,title = {The Inventor Mentor: Programming Object-Oriented + 3D Graphics with Open Inventor, Release 2} + ,publisher = addison + ,year = 1994 + ,update = "97.04 kettner" +} + +@manual{ w-fum-92 + ,title = {{FunnelWeb} User's Manual} + ,author = {Ross N. Williams} + ,edition = {{V1.0} for {FunnelWeb} {V3.0}} + ,year = 1992 + ,month = may + ,update = "98.01 kettner" +} + +%% Updates by Stefan for CGAL paper, which do not follow geombib conventions. + +@inproceedings{ Me-Naeher:IFIP94 + ,author = {K. Mehlhorn and S. N\"aher} + ,title = {The Implementation of Geometric Algorithms} + ,booktitle = {13th World Computer Congress IFIP94} + ,publisher = {Elsevier Science B.V. North-Holland, Amsterdam} + ,volume = {1} + ,pages = {223--231} + ,year = {1994} + ,update = "98.01 schirra" +} + +@incollection{ s-purigc-handbook + ,key = {Sch} + ,author = "S. Schirra" + ,title = "Precision and Robustness Issues in Geometric Computation" + ,booktitle = "Handbook on Computational Geometry" + ,editors = "J. R. Sack and J. Urrutia" + ,publisher = elsevier + ,year = "1998" + ,update = "98.01 schirra" +} + +@manual{ Protocgal + ,author = {Avnaim, F.} + ,title = "{C}{\tt ++}{GAL}: {A} {C}{\tt ++} Library for Geometric + Algorithms" + ,organization = {INRIA Sophia-Antipolis} + ,year = 1994 + ,update = "98.01 schirra" +} + +@manual{ PlaGeo + ,author = {Giezeman, G.-J.} + ,title = {{PlaGeo}, a library for planar geometry, and {SpaGeo}, + a library for spatial geometry} + ,organization = {Utrecht University} + ,year = 1994 + ,update = "98.01 schirra" +} + +@article{ LEDA_ACM + ,author = {Mehlhorn, K. and N\"aher, S.} + ,title = {{LEDA}, a Platform for Combinatorial and + Geometric Computing} + ,journal = {Communications of the ACM} + ,volume = {38} + ,pages = {96-102} + ,year = {1995} + ,update = "98.01 schirra" +} + +%% manuscript{ geomlib ?? + +@misc{ geomlib + ,author = {Baker, J. E. and Tamassia, R. and Vismara, L.} + ,title = {{GeomLib}: {A}lgorithm Engineering for a Geometric + Computing Library} + ,note = {(Preliminary report)} + ,institution = {Center for Geometric Computing} + ,year = {1997} + ,update = "98.01 schirra" +} + +@manual{ gmp + ,title = {{GNU MP}, The {GNU} Multiple Precision Arithmetic Library} + ,author = {Granlund, T.} + ,edition = {2.0.2} + ,month = {June} + ,year = {1996} + ,update = "98.01 schirra" +} + +@techreport{ reals_TR + ,author = {Burnikel, C. and Mehlhorn, K. and Schirra, S.} + ,title = {The {LEDA} Class {\tt real} Number} + ,institution = {Max-Planck-Institut f\"ur Informatik} + ,number = {MPI-I-96-1-001} + ,year = 1996 + ,update = "98.01 schirra" +} + +@techreport{bp_lsi_TR + ,author = "Boissonnat, J.-D. and Preparata, F." + ,title = "Robust plane sweep for intersecting segments" + ,institution = {INRIA} + ,address = {Sophia-Antipolis, France} + ,number = {3270} + ,year = {September 1997} + ,update = "98.01 schirra" +} + +@incollection{ cgal-nt-98 + ,author = {{CGAL} consortium} + ,title = {Number Types} + ,booktitle = {{CGAL} Reference Manual. {P}art 3: {S}upport Library} + ,editor = {Herv\'e Br\"onnimann and Andreas Fabri and + Stefan Schirra and Remco Veltkamp} + ,year = 1998 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "98.01 giezeman, 98.01 schönherr, 98.02 schirra" +} + +@manual{ gvw-gsc-98 + ,author = {Geert-Jan Giezeman and Remco Veltkamp and + Wieger Wesselink} + ,title = {Getting Started with {CGAL}} + ,year = 1998 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "98.01 schönherr" +} + +@incollection{ k-ps-98 + ,author = {Lutz Kettner} + ,title = {{3D}-Polyhedral Surfaces} + ,booktitle = {{CGAL} Reference Manual. Part 2: Basic Library} + ,editor = {Herv\'e Br\"onnimann and Andreas Fabri and + Stefan Schirra and Remco Veltkamp} + ,year = 1998 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "97.12 kettner, 98.01 schönherr, 98.02 schirra" +} + +@incollection{ k-c-98 + ,author = {Lutz Kettner} + ,title = {Circulators} + ,booktitle = {{CGAL} Reference Manual. Part 3: Support Library} + ,editor = {Herv\'e Br\"onnimann and Andreas Fabri and + Stefan Schirra and Remco Veltkamp} + ,year = 1998 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "97.12 kettner, 98.01 schönherr, 98.02 schirra" +} + +%% EOF %% diff --git a/Packages/Timer/doc_tex/Timer/main.tex b/Packages/Timer/doc_tex/Timer/main.tex new file mode 100644 index 00000000000..8d5e2c155d7 --- /dev/null +++ b/Packages/Timer/doc_tex/Timer/main.tex @@ -0,0 +1,11 @@ +% +------------------------------------------------------------------------+ +% | CGAL Reference Manual: main.tex +% +------------------------------------------------------------------------+ +% | Timer for CGAL +% | +% | 04.03.1999 Lutz Kettner +% +------------------------------------------------------------------------+ + +\input{timer} + +%% EOF %% diff --git a/Packages/Timer/doc_tex/Timer/timer.tex b/Packages/Timer/doc_tex/Timer/timer.tex new file mode 100644 index 00000000000..3b89e78e5a0 --- /dev/null +++ b/Packages/Timer/doc_tex/Timer/timer.tex @@ -0,0 +1,129 @@ +% +------------------------------------------------------------------------+ +% | CGAL Reference Manual: timer.tex +% +------------------------------------------------------------------------+ + +\ccParDims + +\chapter{Timer} +\label{chapterTimer} +\ccChapterAuthor{Lutz Kettner, Matthias B\"asken} + +\section{Introduction} + +This chapter decribes classes for measuring user process time and real time. + +\begin{ccRefClass}{Timer} +\ccSection{A Timer for User-Process Time} + +\ccDefinition +\ccCreationVariable{t} + +A timer \ccVar\ of type \ccRefName\ is an object with a state. It is +either {\em running\/} or it is {\em stopped}. The state is controlled +with \ccStyle{t.start()} and \ccStyle{t.stop()} . The timer counts the +time elapsed since its creation or last reset. It counts only the time +where it is in the running state. The time information is given in seconds. +The timer counts also the number of intervals it was running, i.e. it +counts the number of calls of the \ccc{start()} member function since the +last reset. If the reset occures while the timer is running it counts as the +first interval. + +\ccInclude{CGAL/Timer.h} + +\ccCreation + +\ccSetThreeColumns{Timer&}{t.is_running();}{} +\ccPropagateThreeToTwoColumns +%\ccSetTwoColumns{Timer t( Timer r);}{} + +\ccConstructor{Timer();}{state is {\em stopped.}} + +\ccOperations + +\ccMethod{void start();}{\ccPrecond state is {\em stopped}.} +\ccGlue +\ccMethod{void stop ();}{\ccPrecond state is {\em running}.} +\ccGlue +\ccMethod{void reset();}{reset timer to zero. The state is unaffected.} +\ccGlue +\ccMethod{bool is_running();}{\ccc{true} if the current state is running.} + +\ccMethod{double time();}{user process time in seconds.} +\ccGlue +\ccMethod{int intervals();}{number of start/stop-intervals since + the last reset.} +\ccGlue +\ccMethod{double precision();}{smallest possible time step in seconds.} +\ccGlue +\ccMethod{double max();}{maximal representable time in seconds.} + + +\ccImplementation + +The timer class is based in the C function \ccStyle{std::clock(\ldots)} +which measures the user and system times of the current process and +its subprocesses. The time granularity is reasonable fine with +currently 10 ms on IRIX and Solaris. However the counter wraps around +after only about 36 minutes. On Solaris machines the man page states +that the timer could fail. In that case an error message is printed +and the program aborted. + +\end{ccRefClass} + +% +----------------------------------------------------------+ +\begin{ccRefClass}{Real_timer} +\ccSection{A Timer Measuring Real-Time} + +\ccDefinition +\ccCreationVariable{t} + +A timer \ccVar\ of type \ccRefName\ is an object with a state. It is +either {\em running\/} or it is {\em stopped}. The state is controlled +with \ccStyle{t.start()} and \ccStyle{t.stop()} . The timer counts the +time elapsed since its creation or last reset. It counts only the time +where it is in the running state. The time information is given in seconds. +The timer counts also the number of intervals it was running, i.e. it +counts the number of calls of the \ccc{start()} member function since the +last reset. If the reset occures while the timer is running it counts as the +first interval. + +\ccInclude{CGAL/Real_timer.h} + +\ccCreation + +\ccSetThreeColumns{Real_timer&}{t.is_running();}{} +\ccPropagateThreeToTwoColumns +%\ccSetTwoColumns{Timer t( Timer r);}{} + +\ccConstructor{Real_timer();}{state is {\em stopped.}} + +\ccOperations + +\ccMethod{void start();}{\ccPrecond state is {\em stopped}.} +\ccGlue +\ccMethod{void stop ();}{\ccPrecond state is {\em running}.} +\ccGlue +\ccMethod{void reset();}{reset timer to zero. The state is unaffected.} +\ccGlue +\ccMethod{bool is_running();}{\ccc{true} if the current state is running.} + +\ccMethod{double time();}{real time in seconds.} +\ccGlue +\ccMethod{int intervals();}{number of start/stop-intervals since + the last reset.} +\ccGlue +\ccMethod{double precision();}{smallest possible time step in seconds; returns -1 if not available.} +\ccGlue +\ccMethod{double max();}{maximal representable time in seconds.} + +\ccImplementation + +The timer class is based in the C function \ccStyle{gettimeofday(\ldots)} on UNIX systems and +\ccStyle{_ftime(\ldots)} on MS Visual C++. +\end{ccRefClass} + +% +--------------------------------------------------------+ +% restore default column and paragraph layout +\ccParDims + +% EOF diff --git a/Packages/Timer/doc_tex/support/Timer/cgal.bib b/Packages/Timer/doc_tex/support/Timer/cgal.bib new file mode 100644 index 00000000000..3e210afc47c --- /dev/null +++ b/Packages/Timer/doc_tex/support/Timer/cgal.bib @@ -0,0 +1,1061 @@ +% ------------------------------------------------------------------------ +% cgal.bib +% -------- +% BiBTeX references used in the CGAL project which are not in geombib. +% geombib is available from: +% +% file://ftp.cs.usask.ca/pub/geometry/geombib.tar.Z +% +% 29.04.1997 Lutz Kettner kettner_inf.ethz.ch +% +% annote entry might contain "recommended C++ reading" or +% "recommended OO reading". +% +% ------------------------------------------------------------------------ + + +% Common abbreviations for publishers, journals, ... +% -------------------------------------------------- + +@string{ addison = {Addison-Wesley}} +@string{ mcgraw = {McGraw-Hill}} +@string{ academic = {Academic Press}} +@string{ springer = {Springer Verlag}} +@string{ oldenbourg = {Oldenbourg Verlag, M\"unchen, Wien}} +@string{ gruyter = {Walter de Gruyter, Berlin}} +@string{ elsevier = {Elsevier Science Publishers, Amsterdam, The + Netherlands}} +@string{ acm = {ACM Press}} +@string{ wiley = {John Wiley \& Sons, New York}} +@string{ cambridge = {Cambridge University Press}} +@string{ kaufmann = {Morgan Kaufmann}} +@string{ kluwer = {Kluwer Academic Publishers Group}} + +% Alphabetically sorted list of references. +% ----------------------------------------- + +@incollection{ a-cgs-97 + ,author = "N. Amenta" + ,title = "Computational Geometry Software" + ,booktitle = "Handbook of Discrete and Computational Geometry" + ,editors = "J. Goodman and J. O'Rourke" + ,publisher = "CRC Press" + ,year = "1997" + ,pages = "951--960" + ,update = "98.01 schirra" +} + +@inproceedings{ a-nqimr-67 + ,author = {Arthur Appel} + ,title = {The Notion of Quantitive Invisibility and the + Machine Rendering of Solids} + ,booktitle = {Proc. ACM National Conf.} + ,year = 1967 + ,pages = {387--393} + ,annote = {Basis for the contour edge idea in hidden surface + removal.} + ,update = "97.04 kettner" +} + +@book{ bn-sec++-94 + ,author = "J. J. Barton and L. R. Nackman" + ,title = "Scientific and Engineering {C{\tt ++}}" + ,publisher = "Addison-Wesley, Reading, MA" + ,year = "1997" + ,update = "98.01 schirra" +} + +@inproceedings{ bfh-mgedm-95 + ,author = {Heinzgerd Bendels and Dieter W. Fellner and Sven + Havemann} + ,title = {Modellierung der Grundlagen: Erweiterbare + Datenstrukturen zur Modellierung und Visualisierung + polygonaler Welten} + ,booktitle = {Modeling -- Virtual Worlds -- Distributed Graphics} + ,year = 1995 + ,editor = {D. W. Fellner} + ,pages = {149--157} + ,address = {Bad Honnef / Bonn} + ,month = {27.--28. November} + ,annote = {A reference for the halfedge data structure and + Euler operators (preserving the topological type).} + ,update = "97.04 kettner" +} + +@misc{ bpp-vrml-95 + ,author = {Gavin Bell and Anthony Parisi and Mark Pesce} + ,title = {VRML The Virtual Reality Modeling Language: + Version 1.0 Specification} + ,howpublished = {\path|http://www.vrml.org/|} + ,month = {May 26} + ,year = 1995 + ,note = {Third Draft} + ,update = "97.04 kettner" +} + +@incollection{ bv-sbc-96 + ,author = "G. Booch and M. Vilot" + ,title = "Simplifying the Booch Components" + ,booktitle = "{\CC\ }Gems" + ,publisher = "SIGS publications" + ,editor = "Lippman, S." + ,year = "1996" + ,pages = "59--89" + ,update = "98.01 schirra" +} + +@incollection{ cgal-nt-97 + ,author = {{CGAL} consortium} + ,title = {Number Types} + ,booktitle = {{CGAL} Reference Manual. {P}art 3: {S}upport Library} + ,editor = {Andreas Fabri and Stefan Schirra and + Remco Veltkamp} + ,year = 1997 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "98.01 giezeman" +} + +@misc{ + ,author = {{CGAL} consortium} + ,title = {{CGAL} Workpackage 4, Report 2} + ,howpublished = {\path|http://www.cs.ruu.nl/CGAL|} + ,month = {fall} + ,year = 1997 + ,update = "98.01 kettner" +} + +@misc{ + ,author = {{CGAL} consortium} + ,title = {{CGAL} Workpackage 4, Report 1} + ,howpublished = {\path|http://www.cs.ruu.nl/CGAL|} + ,month = apr + ,year = 1997 + ,update = "98.01 kettner" +} + +@inproceedings{ cvmtwabw-se-96 + ,author = {Jonathan Cohen and Amitabh Varshney and Dinesh + Manocha and Greg Turk and Hans Weber and Pankaj + Agarwal and Frederick Brooks and William Wright} + ,title = {Simplification Envelopes} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '96)" + ,volume = 30 + ,year = 1996 + ,pages = {119--128} + ,note = {Examples and code in + \path|http://www.cs.unc.edu/~geom/envelope.html|} + ,update = "97.08 kettner" +} + +@inproceedings{ cl-vmbcm-96 + ,author = {Brian Curless and Marc Levoy} + ,title = {A Volumetric Method for Building Complex + Models from Range Images} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '96)" + ,volume = 30 + ,year = 1996 + ,pages = {303--312} + ,update = "97.08 kettner" +} + +@misc{ c-wpdpi-95 + ,key = {C++AnsiDraft} + ,title = "Working Paper for Draft Proposed International + Standard for Information Systems -- Programming + Language {C{\tt ++}}" + ,howpublished = {ANSI X3, Information Processing Systems} + ,month = apr + ,year = 1995 + ,note = {\path|http://www.cygnus.com/misc/wp/|} + ,update = "97.04 kettner" +} + +@misc{ c-wpdpi-96 + ,key = {{C}{\tt ++}} + ,title = "Working Paper for Draft Proposed International + Standard for Information Systems -- Programming + Language {C{\tt ++}}" + ,howpublished = {Doc.~No.~X3J16/96 - 0225 - WG21/N1043} + ,month = Dec + ,year = 1996 + ,note = {\path|http://www.maths.warwick.ac.uk/c++/pub/|} + ,update = "97.04 kettner, 98.02 schirra" +} + +@misc{ c-isplc-98 + ,key = {{C}{\tt ++}} + ,title = "International Standard ISO/IEC 14882: + Programming languages -- {C{\tt ++}}" + ,howpublished = {American National Standards Institute, 11 West 42nd + Street, New York 10036} + ,year = 1998 + ,mynote = {\path|http://webstore.ansi.org/|} + ,update = "99.02 kettner" +} + +@misc{ c-isplc-98 + ,key = {{C}{\tt ++}} + ,title = "International Standard ISO/IEC 14882: + Programming languages -- {C{\tt ++}}" + ,howpublished = {American National Standards Institute, 11 West 42nd + Street, New York 10036} + ,year = 1998 + ,mynote = {\path|http://webstore.ansi.org/|} + ,update = "98.11 kettner" +} + +@misc{ OLD-c-wpdpi-96 + ,key = {C++AnsiDraft} + ,title = "Working Paper for Draft Proposed International + Standard for Information Systems -- Programming + Language {C{\tt ++}}" + ,howpublished = {ANSI X3, Information Processing Systems} + ,month = dec + ,year = 1996 + ,note = {\path|http://www.maths.warwick.ac.uk/c++/pub/|} + ,update = "97.04 kettner" +} + +@inproceedings{ eddhls-maam-95 + ,author = {Matthias Eck and Tony DeRose and Tom Duchamp and + Hugues Hoppe and Michael Lounsbery and Werner Stuetzle} + ,title = {Multiresolution Analysis of Arbitrary Meshes} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '95)" + ,volume = 29 + ,year = 1995 + ,pages = {173--182} + ,note = {Examples in + \path|file://ftp.cs.washington.edu/pub/graphics|} + ,update = "97.08 kettner" +} + +@inproceedings{ fgkss-ckbgc-96 + ,author = {Andreas Fabri and Geert-Jan Giezeman and Lutz + Kettner and Stefan Schirra and Sven Sch{\"o}nherr} + ,title = {The {CGAL} Kernel: A Basis for Geometric Computation} + ,booktitle = {ACM Workshop on Applied Computational Geometry} + ,editor = {M. C. Lin and D. Manocha} + ,address = {Philadelphia, Pennsylvenia} + ,month = {May, 27--28} + ,year = 1996 + ,pages = {191--202} + ,note = {Springer Lecture Notes in Computer Science 1148} + ,update = "97.04 kettner" +} + +@book{ f-sec-85 + ,author = {Richard Fairley} + ,title = {Software Engineering Concepts} + ,publisher = {McGraw-Hill} + ,year = 1985 + ,series = {McGraw-Hill Series in Software Engineering and Technology} + ,annote = {recommended software engineering reading. + Topics from pre-object-oriented software engineering.} + ,update = "98.01 kettner" +} + +@book{ ghjv-dpero-95 + ,author = {E. Gamma and R. Helm and R. Johnson and J. Vlissides} + ,title = {Design Patterns -- Elements of Reusable + Object-Oriented Software} + ,publisher = addison + ,year = 1995 + ,annote = {recommended OO reading.} + ,update = "97.04 kettner" +} + +@article{ g-ieva-85 + ,author = {Ronald N. Goldman} + ,title = {Illicit Expressions in Vector Algebra} + ,journal = {ACM Transaction on Graphics} + ,year = 1985 + ,volume = 4 + ,number = 3 + ,month = jul + ,pages = {223--243} + ,update = "98.01 kettner" +} + +@book{ hw-vrml2h-96 + ,author = {Jed Hartman and Josie Wernecke} + ,title = {The {VRML} 2.0 Handbook: Building Moving Worlds on the + Web} + ,publisher = addison + ,year = 1996 + ,annote = {The VRML 2.0 Introduction and Reference by + Silicon Graphics.} + ,update = "98.02 kettner" +} + +@misc{ h-97 + ,author = {Michael Hoffmann} + ,year = 1997 + ,note = {personal communication} + ,update = "98.01 kettner" +} + +@inproceedings{ hddms-srup-92 + ,author = {Hugues Hoppe and Tony DeRose and Tom Duchamp and + John McDonald and Werner Stuetzle} + ,title = {Surface Reconstruction from Unorganized Points} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '90)" + ,volume = 26 + ,year = 1992 + ,pages = {71--77} + ,update = "97.08 kettner" +} + +@inproceedings{ hddms-mo-93 + ,author = {Hugues Hoppe and Tony DeRose and Tom Duchamp and + John McDonald and Werner Stuetzle} + ,title = {Mesh Optimization} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '93)" + ,volume = 27 + ,year = 1993 + ,pages = {19--26} + ,note = {Examples and code in + \path|file://ftp.cs.washington.edu/pub/graphics|} + ,update = "97.08 kettner" +} + +@phdthesis{ h-srup-94 + ,author = {Hugues Hoppe} + ,title = {Surface reconstruction from unorganized points} + ,school = {University of Washington} + ,year = 1994 + ,update = "97.08 kettner" +} + +@inproceedings{ hddhjmss-pssr-94 + ,author = {Hugues Hoppe and Tony DeRose and Tom Duchamp and + Mark Halstaed and Hubert Jin and John McDonald and + Jean Schweitzer and Werner Stuetzle} + ,title = {Piecewise Smooth Surface Reconstruction} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '94)" + ,volume = 28 + ,year = 1994 + ,pages = {295--302} + ,note = {Examples and code in + \path|file://ftp.cs.washington.edu/pub/graphics|} + ,update = "97.08 kettner" +} + +@inproceedings{ h-pm-96 + ,author = {Hugues Hoppe} + ,title = {Progressive Meshes} + ,booktitle = "Computer Graphics (Proc. SIGGRAPH '96)" + ,volume = 30 + ,year = 1996 + ,pages = {99--108} + ,update = "97.08 kettner" +} + +@incollection{ k-dat-96 + ,author = "Keffer, T." + ,title = "The Design and Architecture of {T}ools.h{\tt ++}" + ,booktitle = "{C{\tt ++}}~Gems" + ,publisher = "SIGS publications" + ,editor = "Lippman, S." + ,year = "1996" + ,pages = "43--57" + ,update = "98.01 schirra" +} + +@incollection{ kw-ceapp-97 + ,author = {Lutz Kettner and Emo Welzl} + ,title = {Contour Edge Analysis for Polyhedron Projections} + ,booktitle = {Geometric Modeling: Theory and Practice} + ,year = 1997 + ,pages = {379--394} + ,publisher = {Springer Verlag} + ,editor = {Wolfgang Strasser and Reinhard Klein and Rene Rau} + ,update = "97.04 kettner, 97.08 kettner" +} + +@incollection{ kw-osepg-98 + ,author = {Lutz Kettner and Emo Welzl} + ,title = {One Sided Error Predicates in Geometric Computing} + ,booktitle = {Proc. 15th IFIP World Computer Congress, + Fundamentals - Foundations of Computer Science} + ,year = 1998 + ,pages = {13--26} + ,editor = {Kurt Mehlhorn} + ,update = "98.08 kettner" +} + +@inproceedings{ k-ddsps-98 + ,author = {Lutz Kettner} + ,title = {Designing a Data Structure for Polyhedral Surfaces} + ,booktitle = {Proc. 14th Annu. ACM Sympos. Comput. Geom.} + ,year = 1998 + ,pages = {146--154} + ,abstract = { + Design solutions for a program library are presented for combinatorial + data structures in computational geometry, such as planar maps and + polyhedral surfaces. Design issues considered are genericity, + flexibility, time and space efficiency, and ease-of-use. We focus on + topological aspects of polyhedral surfaces. Edge-based representations + for polyhedrons are evaluated with respect to the design goals. A + design for polyhedral surfaces in a halfedge data structure is + developed following the generic programming paradigm known from the + Standard Template Library STL for C++. Connections are shown to planar + maps and face-based structures managing holes in facets} +} + +@techreport{ k-ddsps-97 + ,author = {Lutz Kettner} + ,title = {Designing a Data Structure for Polyhedral Surfaces} + ,institution = {Department Informatik, ETH Z{\"u}rich} + ,year = 1997 + ,type = {Technical Report} + ,number = {\#278} + ,address = {Switzerland} + ,pages = {27} + ,month = dec + ,abstract = { + Design solutions for a program library are presented for combinatorial + data structures in computational geometry, such as planar maps and + polyhedral surfaces. Design issues considered are genericity, + flexibility, time and space efficiency, and ease-of-use. We focus on + topological aspects of polyhedral surfaces. Edge-based representations + for polyhedrons are evaluated with respect to the design goals. A + design for polyhedral surfaces in a halfedge data structure is + developed following the generic programming paradigm known from the + Standard Template Library STL for C++. Connections are shown to planar + maps and face-based structures managing holes in facets} + ,update = "98.01 kettner" +} + +@incollection{ k-ps-97 + ,author = {Lutz Kettner} + ,title = {{3D}-Polyhedral Surfaces} + ,booktitle = {{CGAL} Reference Manual. Part 2: Basic Library} + ,editor = {Andreas Fabri and Stefan Schirra and Remco Veltkamp} + ,year = 1997 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "97.12 kettner" +} + +@incollection{ k-c-97 + ,author = {Lutz Kettner} + ,title = {Circulators} + ,booktitle = {{CGAL} Reference Manual. Part 3: Support Library} + ,editor = {Andreas Fabri and Stefan Schirra and Remco Veltkamp} + ,year = 1997 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "97.12 kettner" +} + +@manual{ kl-cssd-94 + ,title = {The {CWEB} System of Structured Documentation} + ,author = {Donald E. Knuth and Silvio Levy} + ,edition = {Version 3.0} + ,year = 1994 + ,update = "98.01 kettner" +} + +@article{ k-lp-84 + ,author = {Donald E. Knuth} + ,title = {Literate Programming} + ,journal = {The Computer Journal} + ,year = 1984 + ,volume = 27 + ,number = 2 + ,pages = {97--111} + ,update = "98.01 kettner" +} + +@article{ kl-isc++l-96 + ,author = "K. Kreft and A. Langer" + ,title = "Iterators in the Standard {\CC\ }Library" + ,journal = "{C{\tt ++}}~Report" + ,volume = "8" + ,number = "10" + ,month = "Nov.-Dec." + ,year = "1996" + ,pages = "27--32" + ,update = "98.01 schirra" +} + +@techreport{ kw-dat-96 + ,author = {Dietmar K{\"u}hl and Karsten Weihe} + ,title = {Data Access Templates} + ,institution = {Universit\"at Konstanz, Germany} + ,year = 1996 + ,type = {Konstanzer Schriften in Mathematik und Informatik} + ,number = {Nr. 9} + ,month = may + ,note = {\path|http://www.informatik.uni-konstanz.de/Schriften|} + ,annote = {recommended C++ reading.} + ,update = "97.04 kettner" +} + +@book{ l-lscsd-96 + ,author = {John Lakos} + ,title = {Large Scale {C{\tt ++}} Software Design} + ,publisher = addison + ,year = 1996 + ,annote = {recommended OO reading.} + ,update = "97.04 kettner" +} + +@inproceedings{ l-vgasa-96 + ,author = "D. T. Lee" + ,title = "Visualizing Geometric Algorithms -- State of the Art" + ,editor = "M. C. Lin and D. Manocha" + ,booktitle = "Applied Computational Geometry (Proc. WACG~'96)" + ,series = "Lecture Notes Comput. Sci." + ,volume = 1148 + ,publisher = "Springer-Verlag" + ,year = 1996 + ,pages = "45--50" + ,update = "98.01 schirra" +} + +@book{ l-icom-96 + ,author = {Stanley B. Lippman} + ,title = {Inside the {C{\tt ++}} Object Model} + ,publisher = addison + ,year = 1996 + ,annote = {Insides into C++ compiler implementations. + Performance issues of various C++ features. } + ,update = "97.04 kettner" +} + +@book{ m-wsc-93 + ,author = {Steve Maguire} + ,title = {Writing Solid Code} + ,publisher = {Microsoft Press} + ,year = 1993 + ,annote = {Microsoft's techniques for developing bug-free C programs} + ,update = "98.01 schirra" +} + +@inproceedings{ m-pppd-96 + ,author = "Kurt Mehlhorn" + ,title = "Position Paper for Panel Discussion" + ,editor = "M. C. Lin and D. Manocha" + ,booktitle = "Applied Computational Geometry (Proc. WACG~'96)" + ,series = "Lecture Notes Comput. Sci." + ,volume = 1148 + ,publisher = "Springer-Verlag" + ,year = 1996 + ,pages = "51--52" + ,update = "98.01 schirra" +} + +@manual{ mnu-lum-97 + ,author = {Mehlhorn, K. and N\"aher, S. and Uhrig, C.} + ,title = {The {LEDA} {U}ser {M}anual, {V}ersion 3.5} + ,organization = {Max-Planck-Insitut f\"ur Informatik} + ,address = {66123 Saarbr\"ucken, Germany} + ,year = {1997} + ,note = {\path|http://www.mpi-sb.mpg.de/LEDA/leda.html|} + ,update = "97.12 kettner, 98.02 schirra" +} + +@manual{ OLD-mnu-lum-97 + ,title = {The {LEDA} {U}ser {M}anual, {V}ersion 3.5} + ,author = {Kurt Mehlhorn and Stefan N{\"a}her and Christian Uhrig} + ,organization = {LEDA Software GmbH} + ,address = {66123 Saarbr\"ucken, Germany} + ,year = 1997 + ,update = "97.12 kettner" +} + +@book{ m-ec-92 + ,author = {Scott Meyers} + ,title = "Effective {C{\tt ++}}" + ,publisher = addison + ,year = 1992 + ,annote = {recommended C++ reading. 50 Specific Ways to + Improve Your Programs and Designs} + ,update = "97.04 schönherr" +} + +@book{ m-mec-96 + ,author = {Scott Meyers} + ,title = "More Effective {C{\tt ++}}" + ,publisher = addison + ,year = 1996 + ,annote = {recommended C++ reading. 35 New Ways to + Improve Your Programs and Designs} + ,update = "97.04 schönherr" +} + +@book{ m-cst-93 + ,author = {Robert B. Murray} + ,title = "{C{\tt ++}} Strategies and Tactics" + ,publisher = addison + ,year = 1993 + ,annote = {recommended C++ reading} + ,update = "98.01 schirra" +} + +@article{ m-tnutt-95 + ,author = {Nathan C. Myers} + ,title = {Traits: a New and Useful Template Technique} + ,journal = "{C{\tt ++}}~Report" + ,year = 1995 + ,month = jun + ,annote = {recommended C++ reading. stream traits, iterator + traits, typedef's.} + ,update = "97.04 kettner" +} + +@inproceedings{ ms-gp-89 + ,author = {David R.~Musser and Alexander A.~Stepanov} + ,title = {Generic Programming} + ,booktitle = {1st Intl.\ Joint Conf.\ of ISSAC-88 and AAEC-6} + ,year = 1989 + ,pages = {13--25} + ,publisher = {Springer LNCS 358} +} + +@article{ ms-aogl-94 + ,author = {David R.~Musser and Alexander A.~Stepanov} + ,title = {Algorithm-oriented Generic Libraries} + ,journal = {Software -- Practice and Experience} + ,year = 1994 + ,volume = 24 + ,number = 7 + ,pages = {623--642} + ,month = jul +} + +@book{ ms-strg-96 + ,author = {David R. Musser and Atul Saini} + ,title = "{STL} Tutorial and Reference Guide: + {C{\tt ++}}~Programming with the Standard Template + Library" + ,publisher = addison + ,year = 1996 + ,annote = {recommended C++ reading.} + ,update = "97.04 kettner" +} + +@manual{ nu-leda32-95 + ,title = {The {L}{E}{D}{A} {U}ser {M}anual, {V}ersion {R} 3.2} + ,author = {S.~N{\"a}her and C.~Uhrig} + ,organization = {Max-Planck-Institut f\"ur Informatik} + ,address = {Saarbr\"ucken, Germany} + ,year = 1995 + ,update = "97.04 kettner" +} + +@book{ ndw-opgog-93 + ,author = {Jackie Neider and Tom Davis and Mason Woo} + ,title = {OpenGL Programming Guide: The Official Guide to + Learning OpenGL, Release 1} + ,publisher = addison + ,year = 1993 + ,update = "97.04 kettner" +} + +@inproceedings{ o-dcgal-96 + ,author = {Mark H. Overmars} + ,title = {Designing the Computational Geometry Algorithms + Library {CGAL}} + ,booktitle = {ACM Workshop on Applied Computational Geometry} + ,editor = {M. C. Lin and D. Manocha} + ,address = {Philadelphia, Pennsylvenia} + ,month = {May, 27--28} + ,year = 1996 + ,note = {Lecture Notes in Computer Science 1148} + ,update = "97.04 kettner" +} + +@article{ pc-rdp-86 + ,author = {David L. Parnas and Paul C. Clements} + ,title = {A Rational Design Process: How and Why to Fake It} + ,journal = {IEEE Transactions on Software Engineering} + ,year = 1986 + ,volume = 12 + ,number = 2 + ,pages = {251-257} + ,update = "98.01 kettner" +} + +@manual{ p-gmgv15-94 + ,title = {Geomview Manual: Geomview Version 1.5 for Silicon + Graphics Workstations} + ,author = {Mark Phillips} + ,organization = {The Geometry Center} + ,address = {University of Minnesota} + ,month = oct + ,year = 1994 + ,note = {\path|http://www.geom.umn.edu/software/download/geomview.html|} + ,annote = {Reference for object file format (OFF).} + ,update = "97.04 kettner" +} + +@book{ rbpel-oomd-91 + ,author = {James Rumbaugh and Michael Blaha and William + Premerlani and Frederick Eddy and William Lorenson} + ,title = {Object-Oriented Modeling and Design} + ,publisher = {Prentice Hall} + ,address = {Englewood Cliffs, NJ} + ,year = 1991 + ,annote = {Object and class diagram notation as used in the + book of design patterns ghjv-dpero-95.} + ,update = "97.04 kettner" +} + +@article{ r-lomom-94 + ,author = {James Rumbaugh} + ,title = {The Life of an Object Model: How the Object-Model + Changes During Development} + ,journal = {Journal of Object-Oriented Programming} + ,year = 1994 + ,volume = 7 + ,number = 1 + ,pages = {24--32} + ,month = {March/April} + ,annote = {Object and class diagram notation as used in the + book of design patterns ghjv-dpero-95.} + ,update = "97.04 kettner" +} + +@misc{ s-dcgal-96 + ,author = "S. Schirra" + ,title = "Designing a Computational Geometry Algorithms Library" + ,howpublished = "Lecture Notes for Advanced School on Algorithmic + Foundations of Geographic Information Systems, CISM, + Udine" + ,month = "September 16-20" + ,year = "1996" + ,update = "98.01 schirra" +} + +@techreport{ s-picpc-98 + ,author = {Schirra, Stefan} + ,title = {Parameterized Implementations of Classical Planar + Convex Hull Algorithms and Extreme Point Computations} + ,type = {Research Report} + ,institution = {Max-Planck-Institut f{\"u}r Informatik} + ,address = {Im Stadtwald, D-66123 Saarbr{\"u}cken, Germany} + ,number = {MPI-I-98-1-003} + ,month = {January} + ,year = {1998} + ,issn = {0946-011X} + ,update = "98.01 schirra" +} + +@incollection{s-ixgpe-91a + ,author = "Peter Schorn" + ,title = "Implementing the {XYZ} {GeoBench}: A programming + environment for geometric algorithms" + ,booktitle = "Computational Geometry --- Methods, Algorithms and + Applications: Proc. Internat. Workshop Comput. + Geom. CG '91" + ,series = "Lecture Notes Comput. Sci." + ,volume = 553 + ,publisher = "Springer-Verlag" + ,year = 1991 + ,pages = "187--202" + ,note = {\path|http://wwwjn.inf.ethz.ch/geobench/XYZGeoBench.html|} + ,update = "94.01 rote, 98.01 kettner" +} + +%%\bibitem{schutte} Michael Schutte, Zufaellige Konvexe Mengen, +%% Diplomarbeit Freie Universitaet Berlin, 1996. + +@mastersthesis{ s-zkm-96 + ,author = {Michael Schutte} + ,title = {Zuf{\"a}llige Konvexe Mengen} + ,school = {Freie Universit{\"a}t Berlin} + ,year = 1996 + ,address = {Germany} +} + +@misc{ sgcsi-stlpg-97 + ,author = {{Silicon Graphics Computer Systems{,} Inc.}} + ,title = {Standard Template Library Programmer's Guide} + ,howpublished = {\path|http://www.sgi.com/Technology/STL/|} + ,year = 1997 + ,annote = {Web reference to the STL from SGI. + recommended C++ and STL reference material.} + ,update = "97.12 kettner" +} + +@article{ ss-ablp-91 + ,author = {Lisa M. C. Smith and Mansur H. Samadzadeh} + ,title = {An Annotated Bibliography of Literate Programming} + ,journal = {ACM SIGPLAN Notices} + ,year = 1991 + ,volume = 26 + ,number = 1 + ,pages = {14--20} + ,month = jan + ,update = "98.01 kettner" +} + +@book{ s-cpl-91 + ,author = {Bjarne Stroustrup} + ,title = "The {C{\tt ++}}~Programming Language" + ,publisher = addison + ,year = 1991 + ,edition = {2nd} + ,annote = {recommended C++ reading.} + ,update = "97.04 kettner" +} + +@book{ s-cpl-97 + ,author = {Bjarne Stroustrup} + ,title = "The {C{\tt ++}}~Programming Language" + ,publisher = addison + ,year = 1997 + ,edition = {3rd} + ,annote = {recommended C++ reading.} + ,update = "97.12 kettner" +} + +@misc{ sl-stl-95 + ,author = {Alexander Stepanov and Meng Lee} + ,title = {The Standard Template Library} + ,howpublished = {\path|http://www.cs.rpi.edu/~musser/doc.ps|} + ,month = oct + ,year = 1995 + ,annote = {recommended C++ reading. Short introduction to the + STL. Precise requirements for the iterators and + containers. Explanation of iterator tags (outdated).} + ,update = "97.04 kettner" +} + +@article{ v-tm-95 + ,author = {Todd Veldhuizen} + ,title = {Template Metaprograms} + ,journal = "{C{\tt ++}}~Report" + ,year = 1995 + ,month = may + ,pages = {36--43} + ,annote = {Prime numbers at compiler time, C++ programs at + compile time, control structures, local variables.} + ,update = "98.01 kettner" +} + +@article{ v-et-95 + ,author = {Todd Veldhuizen} + ,title = {Expressions Templates} + ,journal = "{C{\tt ++}}~Report" + ,year = 1995 + ,month = jun + ,pages = {26--31} + ,annote = {Inlining vector expressions and parameter passing + of expressions at compile time. Template Metaprograms.} + ,update = "98.01 kettner" +} + +@article{ v-lactm-96 + ,author = {Todd Veldhuizen and Kumaraswamy Ponnambalam} + ,title = {Linear Algebra with {C{\tt ++}} Template Metaprograms} + ,journal = {Dr. Dobb's Journal} + ,year = 1996 + ,month = aug + ,annote = {Vector operations without temporary variables.} + ,update = "98.01 kettner" +} + +@inproceedings{ v-gpc-97 + ,author = "R. C. Veltkamp" + ,title = "Generic Programming in {CGAL}, the Computational + Geometry Algorithms Library" + ,booktitle = "Proceedings of the 6th Eurographics Workshop on + Programming Paradigms in Graphics" + ,year = "1997" + ,update = "98.01 schirra" +} + +@misc{ vrmls-96 + ,key = {VRML2} + ,title = {The Virtual Reality Modeling Language Specification: + Version 2.0, {ISO}/{IEC} {CD} 14772} + ,howpublished = {\path|http://www.vrml.org/|} + ,month = {August 4} + ,year = 1996 + ,update = "98.01 kettner" +} + +@incollection{ w-fvt-90 + ,author = {Bob Wallis} + ,title = {Forms, Vectors, and Transforms} + ,booktitle = {Graphics Gems} + ,publisher = academic + ,year = 1990 + ,editor = {Andrew S. Glassner} + ,pages = {533-538} + ,annote = {Normal vectors under affine transformations, + tensor algebra and differential geometry, triangular + interpolants, subdeviding a parametric polynomial + curve} + ,update = "98.01 kettner" +} + +@article{ w-ebdss-85 + ,author = {Kevin Weiler} + ,title = {Edge-Based Data Structures for Solid Modeling in + Curved-Surface Environments} + ,journal = {IEEE Computer Graphics and Application} + ,year = 1985 + ,volume = 5 + ,number = 1 + ,pages = {21--40} + ,month = jan + ,annote = {Good halfedge reference. reference from Foley90} + ,update = "98.01 kettner" +} + +@book{ w-impoo-94 + ,author = {Josie Wernicke} + ,title = {The Inventor Mentor: Programming Object-Oriented + 3D Graphics with Open Inventor, Release 2} + ,publisher = addison + ,year = 1994 + ,update = "97.04 kettner" +} + +@manual{ w-fum-92 + ,title = {{FunnelWeb} User's Manual} + ,author = {Ross N. Williams} + ,edition = {{V1.0} for {FunnelWeb} {V3.0}} + ,year = 1992 + ,month = may + ,update = "98.01 kettner" +} + +%% Updates by Stefan for CGAL paper, which do not follow geombib conventions. + +@inproceedings{ Me-Naeher:IFIP94 + ,author = {K. Mehlhorn and S. N\"aher} + ,title = {The Implementation of Geometric Algorithms} + ,booktitle = {13th World Computer Congress IFIP94} + ,publisher = {Elsevier Science B.V. North-Holland, Amsterdam} + ,volume = {1} + ,pages = {223--231} + ,year = {1994} + ,update = "98.01 schirra" +} + +@incollection{ s-purigc-handbook + ,key = {Sch} + ,author = "S. Schirra" + ,title = "Precision and Robustness Issues in Geometric Computation" + ,booktitle = "Handbook on Computational Geometry" + ,editors = "J. R. Sack and J. Urrutia" + ,publisher = elsevier + ,year = "1998" + ,update = "98.01 schirra" +} + +@manual{ Protocgal + ,author = {Avnaim, F.} + ,title = "{C}{\tt ++}{GAL}: {A} {C}{\tt ++} Library for Geometric + Algorithms" + ,organization = {INRIA Sophia-Antipolis} + ,year = 1994 + ,update = "98.01 schirra" +} + +@manual{ PlaGeo + ,author = {Giezeman, G.-J.} + ,title = {{PlaGeo}, a library for planar geometry, and {SpaGeo}, + a library for spatial geometry} + ,organization = {Utrecht University} + ,year = 1994 + ,update = "98.01 schirra" +} + +@article{ LEDA_ACM + ,author = {Mehlhorn, K. and N\"aher, S.} + ,title = {{LEDA}, a Platform for Combinatorial and + Geometric Computing} + ,journal = {Communications of the ACM} + ,volume = {38} + ,pages = {96-102} + ,year = {1995} + ,update = "98.01 schirra" +} + +%% manuscript{ geomlib ?? + +@misc{ geomlib + ,author = {Baker, J. E. and Tamassia, R. and Vismara, L.} + ,title = {{GeomLib}: {A}lgorithm Engineering for a Geometric + Computing Library} + ,note = {(Preliminary report)} + ,institution = {Center for Geometric Computing} + ,year = {1997} + ,update = "98.01 schirra" +} + +@manual{ gmp + ,title = {{GNU MP}, The {GNU} Multiple Precision Arithmetic Library} + ,author = {Granlund, T.} + ,edition = {2.0.2} + ,month = {June} + ,year = {1996} + ,update = "98.01 schirra" +} + +@techreport{ reals_TR + ,author = {Burnikel, C. and Mehlhorn, K. and Schirra, S.} + ,title = {The {LEDA} Class {\tt real} Number} + ,institution = {Max-Planck-Institut f\"ur Informatik} + ,number = {MPI-I-96-1-001} + ,year = 1996 + ,update = "98.01 schirra" +} + +@techreport{bp_lsi_TR + ,author = "Boissonnat, J.-D. and Preparata, F." + ,title = "Robust plane sweep for intersecting segments" + ,institution = {INRIA} + ,address = {Sophia-Antipolis, France} + ,number = {3270} + ,year = {September 1997} + ,update = "98.01 schirra" +} + +@incollection{ cgal-nt-98 + ,author = {{CGAL} consortium} + ,title = {Number Types} + ,booktitle = {{CGAL} Reference Manual. {P}art 3: {S}upport Library} + ,editor = {Herv\'e Br\"onnimann and Andreas Fabri and + Stefan Schirra and Remco Veltkamp} + ,year = 1998 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "98.01 giezeman, 98.01 schönherr, 98.02 schirra" +} + +@manual{ gvw-gsc-98 + ,author = {Geert-Jan Giezeman and Remco Veltkamp and + Wieger Wesselink} + ,title = {Getting Started with {CGAL}} + ,year = 1998 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "98.01 schönherr" +} + +@incollection{ k-ps-98 + ,author = {Lutz Kettner} + ,title = {{3D}-Polyhedral Surfaces} + ,booktitle = {{CGAL} Reference Manual. Part 2: Basic Library} + ,editor = {Herv\'e Br\"onnimann and Andreas Fabri and + Stefan Schirra and Remco Veltkamp} + ,year = 1998 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "97.12 kettner, 98.01 schönherr, 98.02 schirra" +} + +@incollection{ k-c-98 + ,author = {Lutz Kettner} + ,title = {Circulators} + ,booktitle = {{CGAL} Reference Manual. Part 3: Support Library} + ,editor = {Herv\'e Br\"onnimann and Andreas Fabri and + Stefan Schirra and Remco Veltkamp} + ,year = 1998 + ,note = {{CGAL} {R}1.0. \path|http://www.cs.ruu.nl/CGAL|.} + ,update = "97.12 kettner, 98.01 schönherr, 98.02 schirra" +} + +%% EOF %% diff --git a/Packages/Timer/doc_tex/support/Timer/main.tex b/Packages/Timer/doc_tex/support/Timer/main.tex new file mode 100644 index 00000000000..8d5e2c155d7 --- /dev/null +++ b/Packages/Timer/doc_tex/support/Timer/main.tex @@ -0,0 +1,11 @@ +% +------------------------------------------------------------------------+ +% | CGAL Reference Manual: main.tex +% +------------------------------------------------------------------------+ +% | Timer for CGAL +% | +% | 04.03.1999 Lutz Kettner +% +------------------------------------------------------------------------+ + +\input{timer} + +%% EOF %% diff --git a/Packages/Timer/doc_tex/support/Timer/timer.tex b/Packages/Timer/doc_tex/support/Timer/timer.tex new file mode 100644 index 00000000000..3b89e78e5a0 --- /dev/null +++ b/Packages/Timer/doc_tex/support/Timer/timer.tex @@ -0,0 +1,129 @@ +% +------------------------------------------------------------------------+ +% | CGAL Reference Manual: timer.tex +% +------------------------------------------------------------------------+ + +\ccParDims + +\chapter{Timer} +\label{chapterTimer} +\ccChapterAuthor{Lutz Kettner, Matthias B\"asken} + +\section{Introduction} + +This chapter decribes classes for measuring user process time and real time. + +\begin{ccRefClass}{Timer} +\ccSection{A Timer for User-Process Time} + +\ccDefinition +\ccCreationVariable{t} + +A timer \ccVar\ of type \ccRefName\ is an object with a state. It is +either {\em running\/} or it is {\em stopped}. The state is controlled +with \ccStyle{t.start()} and \ccStyle{t.stop()} . The timer counts the +time elapsed since its creation or last reset. It counts only the time +where it is in the running state. The time information is given in seconds. +The timer counts also the number of intervals it was running, i.e. it +counts the number of calls of the \ccc{start()} member function since the +last reset. If the reset occures while the timer is running it counts as the +first interval. + +\ccInclude{CGAL/Timer.h} + +\ccCreation + +\ccSetThreeColumns{Timer&}{t.is_running();}{} +\ccPropagateThreeToTwoColumns +%\ccSetTwoColumns{Timer t( Timer r);}{} + +\ccConstructor{Timer();}{state is {\em stopped.}} + +\ccOperations + +\ccMethod{void start();}{\ccPrecond state is {\em stopped}.} +\ccGlue +\ccMethod{void stop ();}{\ccPrecond state is {\em running}.} +\ccGlue +\ccMethod{void reset();}{reset timer to zero. The state is unaffected.} +\ccGlue +\ccMethod{bool is_running();}{\ccc{true} if the current state is running.} + +\ccMethod{double time();}{user process time in seconds.} +\ccGlue +\ccMethod{int intervals();}{number of start/stop-intervals since + the last reset.} +\ccGlue +\ccMethod{double precision();}{smallest possible time step in seconds.} +\ccGlue +\ccMethod{double max();}{maximal representable time in seconds.} + + +\ccImplementation + +The timer class is based in the C function \ccStyle{std::clock(\ldots)} +which measures the user and system times of the current process and +its subprocesses. The time granularity is reasonable fine with +currently 10 ms on IRIX and Solaris. However the counter wraps around +after only about 36 minutes. On Solaris machines the man page states +that the timer could fail. In that case an error message is printed +and the program aborted. + +\end{ccRefClass} + +% +----------------------------------------------------------+ +\begin{ccRefClass}{Real_timer} +\ccSection{A Timer Measuring Real-Time} + +\ccDefinition +\ccCreationVariable{t} + +A timer \ccVar\ of type \ccRefName\ is an object with a state. It is +either {\em running\/} or it is {\em stopped}. The state is controlled +with \ccStyle{t.start()} and \ccStyle{t.stop()} . The timer counts the +time elapsed since its creation or last reset. It counts only the time +where it is in the running state. The time information is given in seconds. +The timer counts also the number of intervals it was running, i.e. it +counts the number of calls of the \ccc{start()} member function since the +last reset. If the reset occures while the timer is running it counts as the +first interval. + +\ccInclude{CGAL/Real_timer.h} + +\ccCreation + +\ccSetThreeColumns{Real_timer&}{t.is_running();}{} +\ccPropagateThreeToTwoColumns +%\ccSetTwoColumns{Timer t( Timer r);}{} + +\ccConstructor{Real_timer();}{state is {\em stopped.}} + +\ccOperations + +\ccMethod{void start();}{\ccPrecond state is {\em stopped}.} +\ccGlue +\ccMethod{void stop ();}{\ccPrecond state is {\em running}.} +\ccGlue +\ccMethod{void reset();}{reset timer to zero. The state is unaffected.} +\ccGlue +\ccMethod{bool is_running();}{\ccc{true} if the current state is running.} + +\ccMethod{double time();}{real time in seconds.} +\ccGlue +\ccMethod{int intervals();}{number of start/stop-intervals since + the last reset.} +\ccGlue +\ccMethod{double precision();}{smallest possible time step in seconds; returns -1 if not available.} +\ccGlue +\ccMethod{double max();}{maximal representable time in seconds.} + +\ccImplementation + +The timer class is based in the C function \ccStyle{gettimeofday(\ldots)} on UNIX systems and +\ccStyle{_ftime(\ldots)} on MS Visual C++. +\end{ccRefClass} + +% +--------------------------------------------------------+ +% restore default column and paragraph layout +\ccParDims + +% EOF diff --git a/Packages/Timer/include/CGAL/Real_timer.h b/Packages/Timer/include/CGAL/Real_timer.h new file mode 100644 index 00000000000..16d8e88a37b --- /dev/null +++ b/Packages/Timer/include/CGAL/Real_timer.h @@ -0,0 +1,190 @@ +// ====================================================================== +// +// Copyright (c) 1997 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------- +// +// release : +// release_date : 2000, August 11 +// +// file : include/CGAL/Real_timer.h +// package : Timer (1.8) +// maintainer : Matthias Baesken +// revision : 1.8 +// revision_date : 11 August 2000 +// author(s) : Lutz Kettner +// Matthias Baesken +// coordinator : INRIA, Sophia Antipolis +// +// A timer class to measure real-time. +// ====================================================================== + +#ifndef CGAL_REAL_TIMER_H +#define CGAL_REAL_TIMER_H 1 + +#ifndef CGAL_BASIC_H +#include +#endif + +#if defined (_MSC_VER) +#define CGAL_PROTECT_SYS_TIME_H +#include +#include +#endif + +#if defined (__BORLANDC__) +#define CGAL_PROTECT_SYS_TIME_H +#include +#include +#endif + +// used for gettimeofday() +#ifndef CGAL_PROTECT_SYS_TIME_H +#include +#define CGAL_PROTECT_SYS_TIME_H +#endif // CGAL_PROTECT_SYS_TIME_H + +CGAL_BEGIN_NAMESPACE + +// SECTION: A Timer Measuring Real-Time +// ======================================================================== +// +// DEFINITION +// +// A timer `t' of type Real_timer is an object with a state. It is +// either running or it is stopped. The state is controlled with +// `t.start()' and `t.stop()' . The timer counts the time elapsed since +// its creation or last reset. It counts only the time where it is in the +// running state. The time information is given in seconds. + +class Real_timer { +private: + +#if !defined (_MSC_VER) && !defined(__BORLANDC__) + typedef struct timeval Timetype; +#else +#if defined (_MSC_VER) + typedef struct _timeb Timetype; //MSC +#else + typedef struct timeb Timetype; //Borland +#endif +#endif + + const inline int get_time(Timetype* t) const; + const inline void report_err() const; + const inline double recalc_time(const Timetype& t) const; + double elapsed; + Timetype started; + int interv; + bool running; + double eps; + +public: + Real_timer() : elapsed(0), interv(0), running(false) {} + + void start(); + void stop (); + void reset(); + bool is_running() const { return running; } + + double time() const; + int intervals() const { return interv; } + double precision() const + { + return -1; + // change it ... + } + double max() const { return double(INT_MAX);} +}; + + +/*****************************************************************************/ + +// private member functions. +// all the platform-specific functions are encapsulated here. + +const inline int Real_timer::get_time(Timetype* t) const { +#if !defined(_MSC_VER) && !defined(__BORLANDC__) + return gettimeofday( t, NULL); +#else +#if defined (_MSC_VER) + _ftime(t); +#else + ftime(t); +#endif + return 0; +#endif +} + +const inline void Real_timer::report_err() const { + #if !defined (_MSC_VER) && !defined(__BORLANDC__) + std::cerr << "Real_timer error: gettimeofday() returned -1.\n" + << std::endl; + CGAL_CLIB_STD::abort(); +#else + std::cout << "Real_timer error!.\n" << std::endl; +#endif +} + +const inline double Real_timer::recalc_time(const Timetype& t) const { +#if !defined(_MSC_VER) && !defined(__BORLANDC__) + return double(t.tv_sec - started.tv_sec) + + double(t.tv_usec - started.tv_usec) / 1000000; +#else + return ((double)(t.time - started.time)) + + ((double)(t.millitm - started.millitm))/1000.0; +#endif +} + +// Member functions Real_timer +// ================================ + +inline void Real_timer::start() { + CGAL_assertion( ! running); + int res=0; + res = get_time(&started); + if ( res < 0) report_err(); + running = true; + ++ interv; +} + +inline void Real_timer::stop() { + CGAL_assertion(running); + Timetype t; + int res=0; + res = get_time(&t); + if ( res < 0) report_err(); + elapsed += recalc_time(t); + running = false; +} + +inline void Real_timer::reset() { + interv = 0; + elapsed = 0; + if (running) { + int res = 0; + res = get_time(&started); + if ( res < 0) report_err(); + ++ interv; + } +} + +inline double Real_timer::time() const { + if (running) { + Timetype t; + int res = 0; + res = get_time(&t); + if ( res < 0) report_err(); + return elapsed + recalc_time(t); + } + return elapsed; +} + +CGAL_END_NAMESPACE + +#endif // CGAL_REAL_TIMER_H // +// EOF // diff --git a/Packages/Timer/include/CGAL/Timer.h b/Packages/Timer/include/CGAL/Timer.h new file mode 100644 index 00000000000..f9f73a81317 --- /dev/null +++ b/Packages/Timer/include/CGAL/Timer.h @@ -0,0 +1,128 @@ +// ====================================================================== +// +// Copyright (c) 1997 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------- +// +// release : +// release_date : 2000, August 11 +// +// file : include/CGAL/Timer.h +// package : Timer (1.8) +// maintainer : Matthias Baesken +// revision : 1.8 +// revision_date : 11 August 2000 +// author(s) : Lutz Kettner +// Matthias Baesken +// coordinator : INRIA, Sophia Antipolis +// +// A timer class to measure cpu time of user-processes. +// ====================================================================== + +#ifndef CGAL_TIMER_H +#define CGAL_TIMER_H 1 + +#ifndef CGAL_BASIC_H +#include +#endif +#ifndef CGAL_PROTECT_CSTDLIB +#include +#define CGAL_PROTECT_CSTDLIB +#endif +#ifndef CGAL_PROTECT_CLIMITS +#include +#define CGAL_PROTECT_CLIMITS +#endif + +// used for clock() +#ifndef CGAL_PROTECT_CTIME +#include +#define CGAL_PROTECT_CTIME +#endif + +CGAL_BEGIN_NAMESPACE + +// SECTION: A Timer for User-Process Time +// ======================================================================== +// +// DEFINITION +// +// A timer `t' of type Timer is an object with a state. It is either +// running or it is stopped. The state is controlled with `t.start()' +// and `t.stop()'. The timer counts the time elapsed since its creation +// or last reset. It counts only the time where it is in the running +// state. The time information is given in seconds. + +class Timer { +private: + CGAL_CLIB_STD::clock_t elapsed; + CGAL_CLIB_STD::clock_t started; + int interv; + bool running; + +public: + Timer() : elapsed(0), started(0), interv(0), running(false) {} + + void start(); + void stop (); + void reset(); + bool is_running() const { return running; } + + double time() const; + int intervals() const { return interv; } + double precision() const { return 0.01; } + double max() const { return 2146.0;} +}; + + +/*****************************************************************************/ + +// Member functions Timer +// =========================== + +inline void Timer::start() { + CGAL_assertion( ! running); + started = CGAL_CLIB_STD::clock(); + if (started == (CGAL_CLIB_STD::clock_t)-1) { + // possible on Solaris according to man-page +#if defined (_MSC_VER) + std::cout << "Timer error: CGAL_CLIB_STD::clock() returned -1.\n"; +#else + std::cerr << "Timer error: CGAL_CLIB_STD::clock() returned -1.\n"; +#endif + CGAL_CLIB_STD::abort(); + } + running = true; + ++ interv; +} + +inline void Timer::stop() { + CGAL_assertion( running); + elapsed += CGAL_CLIB_STD::clock() - started; + running = false; +} + +inline void Timer::reset() { + interv = 0; + elapsed = 0; + if (running) { + started = CGAL_CLIB_STD::clock(); + ++ interv; + } +} + +inline double Timer::time() const { + if (running) { + return double( elapsed + CGAL_CLIB_STD::clock() - started) / CLOCKS_PER_SEC; + } + return double(elapsed) / CLOCKS_PER_SEC; +} + +CGAL_END_NAMESPACE + +#endif // CGAL_TIMER_H // +// EOF // diff --git a/Packages/Timer/long_description.txt b/Packages/Timer/long_description.txt new file mode 100644 index 00000000000..e9494d594c9 --- /dev/null +++ b/Packages/Timer/long_description.txt @@ -0,0 +1,8 @@ +Timer Package +--------------------------------------------------------------------- + + - CGAL/Timer.h Timer classes for user-process time. + - CGAL/Real_timer.h Timer class for real-time. + - test/Timer/test_timer.C Test program for both timer classes. + +Lutz Kettner diff --git a/Packages/Timer/test/Timer/cgal_test b/Packages/Timer/test/Timer/cgal_test new file mode 100755 index 00000000000..8b74473da9c --- /dev/null +++ b/Packages/Timer/test/Timer/cgal_test @@ -0,0 +1,73 @@ +#! /bin/sh + +# This is a script for the CGAL test suite. Such a script must obey +# the following rules: +# +# - the name of the script is cgal_test +# - for every target two one line messages are written to the file 'error.txt' +# the first one indicates if the compilation was successful +# the second one indicates if the execution was successful +# if one of the two was not successful, the line should start with 'ERROR:' +# - running the script should not require any user interaction +# - the script should clean up object files and executables + +ERRORFILE=error.txt + +#---------------------------------------------------------------------# +# compile_and_run +#---------------------------------------------------------------------# + +compile_and_run() +{ + echo "Compiling $1 ... " + if eval 'make CGAL_MAKEFILE=$CGAL_MAKEFILE \ + TESTSUITE_CXXFLAGS="$TESTSUITE_CXXFLAGS" \ + TESTSUITE_LDFLAGS="$TESTSUITE_LDFLAGS" $1' ; then + echo " compilation of $1 succeeded" >> $ERRORFILE + else + echo " ERROR: compilation of $1 failed" >> $ERRORFILE + fi + + if [ -f $1 ] ; then + OUTPUTFILE=ProgramOutput.$1.$PLATFORM + rm -f $OUTPUTFILE + COMMAND="./$1" + if [ -f $1.cmd ] ; then + COMMAND="$COMMAND `cat $1.cmd`" + fi + if [ -f $1.cin ] ; then + COMMAND="cat $1.cin | $COMMAND" + fi + echo "Executing $1 ... " + echo + if eval 2>&1 $COMMAND > $OUTPUTFILE ; then + echo " execution of $1 succeeded" >> $ERRORFILE + else + echo " ERROR: execution of $1 failed" >> $ERRORFILE + fi + else + echo " ERROR: could not execute $1" >> $ERRORFILE + fi + + eval "2>&1 make CGAL_MAKEFILE=$CGAL_MAKEFILE clean > /dev/null " +} + +#---------------------------------------------------------------------# +# remove the previous error file +#---------------------------------------------------------------------# + +rm -f $ERRORFILE +touch $ERRORFILE + +#---------------------------------------------------------------------# +# compile and run the tests +#---------------------------------------------------------------------# + +if [ $# -ne 0 ] ; then + for file in $* ; do + compile_and_run $file + done +else + compile_and_run test_timer +fi + diff --git a/Packages/Timer/test/Timer/test_timer.C b/Packages/Timer/test/Timer/test_timer.C new file mode 100644 index 00000000000..236250719a0 --- /dev/null +++ b/Packages/Timer/test/Timer/test_timer.C @@ -0,0 +1,88 @@ +// ============================================================================ +// +// Copyright (c) 1997 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------------- +// +// release : $CGAL_Revision: $ +// release_date : $CGAL_Date: $ +// +// file : test_timer.C +// chapter : $CGAL_Chapter: Timer $ +// package : $CGAL_Package: Timer 1.4 (20 Sept 1999) $ +// source : test_timer.C +// revision : $Revision$ +// revision_date : $Date$ +// author(s) : Lutz Kettner +// Matthias Baesken +// coordinator : INRIA, Sophia Antipolis +// +// test Timer.h and real_timer.h +// ============================================================================ + +#include +#include +#include + +void test_timer() { + CGAL::Timer t; + CGAL_assertion( ! t.is_running()); + t.start(); + CGAL_assertion( t.is_running()); + t.reset(); + CGAL_assertion( t.is_running()); + t.stop(); + CGAL_assertion( ! t.is_running()); + CGAL_assertion( t.time() >= 0.0); + std::cout << t.time() << "\n"; + CGAL_assertion( t.intervals() == 1); + CGAL_assertion( t.precision() >= 0.0); + std::cout << t.precision() << "\n"; + CGAL_assertion( t.max() > 0.0); +} + +void test_real_timer() { + CGAL::Real_timer t; + CGAL_assertion( ! t.is_running()); + t.start(); + CGAL_assertion( t.is_running()); + t.reset(); + CGAL_assertion( t.is_running()); + t.stop(); + CGAL_assertion( ! t.is_running()); + CGAL_assertion( t.time() >= 0.0); + std::cout << t.time() << "\n"; + CGAL_assertion( t.intervals() == 1); + CGAL_assertion( t.max() > 0.0); +} + +int main(){ + test_timer(); + test_real_timer(); + CGAL::Real_timer Tm; + CGAL::Timer Tm2; + Tm.start(); + Tm2.start(); + int i1,i2; + double p; + + std::cout << "\n"; + for (i1=0;i1<5;i1++) { + for (i2=0;i2<800000;i2++) p=p+1.0 ; + std::cout << Tm.time() << "\n"; + } + std::cout << "\n"; + + for (i1=0;i1<5;i1++) { + for (i2=0;i2<800000;i2++) p=p+1.0 ; + std::cout << Tm2.time() << "\n"; + } + std::cout << "\n"; + + return 0; +} +// EOF // diff --git a/Packages/Timer/version b/Packages/Timer/version new file mode 100644 index 00000000000..10adefebb6b --- /dev/null +++ b/Packages/Timer/version @@ -0,0 +1,2 @@ +1.8 (11 August 2000) +maintainer: Matthias Baesken