From 3f2af65ef392cbd95dcaa237adfa8d3d27196346 Mon Sep 17 00:00:00 2001 From: Monique Teillaud Date: Tue, 11 May 1999 13:28:16 +0000 Subject: [PATCH] *** empty log message *** --- .../demo/Triangulation_3/README | 11 + .../demo/Triangulation_3/demo.C | 205 ++++++++++++++++++ .../demo/Triangulation_3/makefile | 80 +++++++ 3 files changed, 296 insertions(+) create mode 100644 Packages/Triangulation_3/demo/Triangulation_3/README create mode 100644 Packages/Triangulation_3/demo/Triangulation_3/demo.C create mode 100644 Packages/Triangulation_3/demo/Triangulation_3/makefile diff --git a/Packages/Triangulation_3/demo/Triangulation_3/README b/Packages/Triangulation_3/demo/Triangulation_3/README new file mode 100644 index 00000000000..1153650704d --- /dev/null +++ b/Packages/Triangulation_3/demo/Triangulation_3/README @@ -0,0 +1,11 @@ +demo.C +------------ +Construction of a Delaunay triangulation. + +Needs an input file "data" containing points (given by x y z) + +Opens a geomview window +Draws the triangulation in geomview +Writes the triangulation into a file "output" +------------ + diff --git a/Packages/Triangulation_3/demo/Triangulation_3/demo.C b/Packages/Triangulation_3/demo/Triangulation_3/demo.C new file mode 100644 index 00000000000..8d580bef721 --- /dev/null +++ b/Packages/Triangulation_3/demo/Triangulation_3/demo.C @@ -0,0 +1,205 @@ +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +typedef CGAL::Cartesian Rep; + +typedef CGAL::Triangulation_geom_traits_3 Gt; +typedef CGAL::Triangulation_vertex_base_3 Vb; +typedef CGAL::Triangulation_cell_base_3 Cb; + +typedef CGAL::Triangulation_data_structure_3 TDS; +typedef CGAL::Triangulation_3 Triangulation; +typedef CGAL::Delaunay_triangulation_3 Delaunay; + +typedef CGAL::Triangulation_vertex_iterator_3 Vertex_iterator; +typedef CGAL::Triangulation_edge_iterator_3 Edge_iterator; +typedef CGAL::Triangulation_cell_iterator_3 Cell_iterator; +typedef CGAL::Triangulation_facet_iterator_3 Facet_iterator; +typedef CGAL::Triangulation_cell_circulator_3 Cell_circulator; + +typedef typename Triangulation::Cell Cell; +typedef typename Triangulation::Vertex Vertex; +typedef typename Triangulation::Cell_handle Cell_handle; +typedef typename Triangulation::Vertex_handle Vertex_handle; +typedef typename Triangulation::Locate_type Locate_type; + +typedef Gt::Point Point; +//typedef CGAL::Point_3 Point; + +////////////////////// +// VISU GEOMVIEW +////////////////////// +template +void visu_cells(CGAL::Geomview_stream & os, const TRIANGULATION & T) +{ + Cell_iterator cit = T.finite_cells_begin(); + Cell_iterator cdone = T.cells_end(); + + if ( cit == cdone ) { cout << "debut=fin" << endl ;} + else { + while(cit != cdone) { + os << T.tetrahedron(&(*cit)); + ++cit; + } + } +} +void visu_cell(CGAL::Geomview_stream & os, Cell_handle c) +{ + os << Gt::Tetrahedron(c->vertex(0)->point(), + c->vertex(1)->point(), + c->vertex(2)->point(), + c->vertex(3)->point()); +} +template +void visu_facets(CGAL::Geomview_stream & os, const TRIANGULATION & T) +{ + Facet_iterator fit = T.finite_facets_begin(); + Facet_iterator fdone = T.facets_end(); + + if ( fit == fdone ) { cout << "debut=fin" << endl ;} + else { + while(fit != fdone) { + os << T.triangle(*fit); + ++fit; + } + } +} +template +void visu_edges(CGAL::Geomview_stream & os, const TRIANGULATION & T) +{ + Edge_iterator eit = T.finite_edges_begin(); + Edge_iterator edone = T.edges_end(); + + if ( eit == edone ) { cout << "debut=fin" << endl ;} + else { + while(eit != edone) { + os << T.segment(*eit); + ++eit; + } + } +} +template +void visu_vertices(CGAL::Geomview_stream & os, const TRIANGULATION & T) +{ + Vertex_iterator vit = T.finite_vertices_begin(); + Vertex_iterator vdone = T.vertices_end(); + + if ( vit == vdone ) { cout << "debut=fin" << endl ;} + else { + while(vit != vdone) { + os << vit->point(); + ++vit; + } + } +} + +////////////////////// +// INSERTION +////////////////////// + +template +void insere(CGAL::Geomview_stream & os, TRIANGULATION & T, Point p) +{ + cout << p << endl; + os << p; + cout << "localisation" << endl; + Triangulation::Locate_type lt; + int li, lj; + Cell_handle c = T.locate( p, lt, li, lj ) ; + switch ( T.dimension() ) { + case 0: + { + pp_vertex(c->vertex(0)); + break; + } + case 1: + { + pp_edge(CGAL::make_triple(c,0,1)); + break; + } + case 2: + { + pp_facet(make_pair(c,3)); + break; + } + case 3: + { + pp_cell(c); + break; + } + } + cout << (int) lt << " " << li << " " << lj << endl; + cout << "insertion " << endl; + T.insert( p ); + affiche_sommets(T); + cout << "validite " << T.is_valid(true) << endl; +} + + +CGAL::Geomview_stream gv(CGAL::Bbox_3(0,0,0, 2, 2, 2)); +Delaunay T; + +int main(int argc, char* argv[]) +{ + + CGAL::Geomview_stream gv(CGAL::Bbox_3(0,0,0, 2, 2, 2)); + + gv.set_line_width(4); + gv.set_trace(false); + gv.set_bg_color(CGAL::Color(200, 200, 200)); + gv.set_face_color(CGAL::RED); + gv.set_edge_color(CGAL::GREEN); + gv.set_vertex_color(CGAL::BLUE); + + Point p0(0,0,0); + Point px(1,0,0); + Point py(0,1,0); + Point pz(0,0,1); + + ifstream iFile("points",ios::in); + if (iFile) cout <<" reading file " + << "points" << endl ; + Point nouv; + if (iFile) { + while ( iFile >> nouv ) { + T.insert(nouv); + } + } + + visu_cells(gv,T); + visu_vertices(gv,T); + visu_edges(gv,T); + + cout << T.is_valid(true); + + ofstream oFileT("output",ios::out); + cout <<" writing file " + << "output" << endl << flush; + oFileT << T; + + char ch; + cout << "donner caractere de fin" << endl; + cin >> ch; + + return 1; +} diff --git a/Packages/Triangulation_3/demo/Triangulation_3/makefile b/Packages/Triangulation_3/demo/Triangulation_3/makefile new file mode 100644 index 00000000000..cd076598de2 --- /dev/null +++ b/Packages/Triangulation_3/demo/Triangulation_3/makefile @@ -0,0 +1,80 @@ +# This is the makefile for compiling a CGAL application. + +#---------------------------------------------------------------------# +# include platform specific settings +#---------------------------------------------------------------------# +# Choose the right include file from the /make directory. + +# CGAL_MAKEFILE = ENTER_YOUR_INCLUDE_MAKEFILE_HERE + +#CGAL_MAKEFILE = /0/prisme_util/CGAL/CGAL-last/make/makefile_sparc_SunOS-5.6_g++-2.8.1_LEDA +#CGAL_MAKEFILE = /0/prisme_util/CGAL/CGAL-last/make/makefile_sparc_SunOS-5.6_CC-4.2_LEDA +#CGAL_MAKEFILE = makefile_cgal_leda361 + +include $(CGAL_MAKEFILE) + +# ---------------------------------------------------------------------# +# compiler flags +#---------------------------------------------------------------------# +# rajouter CGAL_LOCAL_CXXFLAGS si on veut les packages de Local +CXXFLAGS = -I../../include \ + -Wall \ + -DCGAL_TRIANGULATION_SHORT_NAMES_3_H \ + $(CGAL_CXXFLAGS) \ + -g #\ + # -B $(UTIL)/Binutils/SunOS/bin/ #$(GCC_EXEC_PREFIX) #pour eg++ + #$(CGAL_LOCAL_CXXFLAGS) \ + #mt -I. -I${OIVHOME}/include #a rajouter pour inventor avec CC + +#libraries used by Inventor +xfc_LIBS=-L${OIVHOME}/lib -L${OGLHOME}/lib -lpthread -lInventorXt -lInventor -limage -lGLU -lGL -lXm -lXt -lXext -lX11 -lXi -ldga -lgen -lnsl -lsocket -lm -ldl +#---------------------------------------------------------------------# +# linker flags +#---------------------------------------------------------------------# + +#LDFLAGS = \ +# $(CGAL_WINDOW_LDFLAGS) -lGeomview -B /u/rigel/0/prisme/spion/BINUTILS/solaris/bin/ +LDFLAGS = \ + $(CGAL_LDFLAGS)# -gstabs \ + #-B $(UTIL)/Binutils/SunOS/bin/ + +#---------------------------------------------------------------------# +# target entries +#---------------------------------------------------------------------# + +all: \ + essai + +demo: demo.o + $(CGAL_CXX) -o demo demo.o $(LDFLAGS) + +essai: essai.o pretty_print.o + $(CGAL_CXX) -o essai essai.o pretty_print.o $(LDFLAGS) + +essaiIv: essaiIv.o + $(CGAL_CXX) -o essaiIv essaiIv.o $(LDFLAGS) ${xfc_LIBS} + +essai_tds: essai_tds.o pretty_print.o + $(CGAL_CXX) -o essai_tds essai_tds.o pretty_print.o $(LDFLAGS) + +clean: + /bin/rm -f *.o \ + essai \ + essai_tds \ + core + +essai.o: ../include/CGAL/*.h pretty_print.h + +essai_tds.o: ../include/CGAL/*.h pretty_print.h + + + +#---------------------------------------------------------------------# +# suffix rules +#---------------------------------------------------------------------# + +.C.o: + $(CGAL_CXX) $(CXXFLAGS) -c $< + + +