diff --git a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/CMakeLists.txt b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/CMakeLists.txt index a0cc57bb9f6..fb6a1a31263 100644 --- a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/CMakeLists.txt +++ b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/CMakeLists.txt @@ -21,9 +21,7 @@ if ( CGAL_FOUND ) include( CGAL_CreateSingleSourceCGALProgram ) include_directories (BEFORE ../../include) -# include_directories (BEFORE ../../../../../trunk/Triangulation_2/include) - create_single_source_cgal_program( "extract.cpp" ) create_single_source_cgal_program( "reconstruction_fct.cpp" ) create_single_source_cgal_program( "reconstruction_class.cpp" ) create_single_source_cgal_program( "reconstruction_polyhedron.cpp" ) diff --git a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_polyhedron.cpp b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_polyhedron.cpp index 4b6da452bf0..47ea0f09a60 100644 --- a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_polyhedron.cpp +++ b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_polyhedron.cpp @@ -22,7 +22,7 @@ int main() std::istream_iterator(), std::back_inserter(points)); - CGAL::advancing_front_surface_reconstruction(points.begin(), + CGAL::advancing_front_surface_reconstructionP(points.begin(), points.end(), P); diff --git a/Advancing_front_surface_reconstruction/include/CGAL/AFSR_vertex_base_3.h b/Advancing_front_surface_reconstruction/include/CGAL/AFSR_vertex_base_3.h deleted file mode 100644 index 1820698a372..00000000000 --- a/Advancing_front_surface_reconstruction/include/CGAL/AFSR_vertex_base_3.h +++ /dev/null @@ -1,473 +0,0 @@ -#ifndef CGAL_AFSR_VERTEX_BASE_3_H -#define CGAL_AFSR_VERTEX_BASE_3_H - -#include - -#include -#include -#include - -#include - -namespace CGAL { - -template > -class AFSR_vertex_base_3 : public VertexBase -{ -public: - - template < typename TDS2 > - struct Rebind_TDS { - typedef typename VertexBase::template Rebind_TDS::Other Vb2; - typedef AFSR_vertex_base_3 Other; - }; - - - typedef VertexBase Base; - typedef typename Base::Vertex_handle Vertex_handle; - typedef typename Base::Cell_handle Cell_handle; - typedef typename VertexBase::Point Point; - typedef double coord_type; - - typedef Triple< Cell_handle, int, int > Edge; - typedef std::pair< Edge, int > Edge_incident_facet; - typedef std::pair< Edge_incident_facet, Edge_incident_facet > IO_edge_type; - - typedef coord_type criteria; - - typedef std::pair< criteria, IO_edge_type > Radius_edge_type; - typedef std::pair< Radius_edge_type, int > Border_elt; - typedef std::pair< Vertex_handle, Border_elt > Next_border_elt; - -private: - - //par convention je remplis d'abord first et si necessaire second... - typedef std::pair< Next_border_elt*, Next_border_elt*> Intern_successors_type; - -public: - - typedef std::pair< criteria, IO_edge_type* > Radius_ptr_type; - typedef std::pair< Vertex_handle, Vertex_handle > Edge_like; - typedef std::pair< criteria, Edge_like > Incidence_request_elt; - typedef std::list< Incidence_request_elt > Incidence_request_type; - typedef typename Incidence_request_type::iterator Incidence_request_iterator; - - // typedef std::set< void* > Interior_edge_set_type; - - //-------------------- DATA MEMBERS --------------------------------- - -private: - - int _mark; - int _post_mark; - Intern_successors_type* _incident_border; - - // Instead of having a set per vertex, there is a global list. - static std::list interior_edges; - // and two iterators per vertex in this list - // Note that ie_last is not past the end - // ie_first == ie_last == interior_edge.end() iff the set is empty - typename std::list::iterator ie_first, ie_last; - - - // We do the same for the incidence requests - static std::list< Incidence_request_elt > incidence_requests; - typename std::list< Incidence_request_elt >::iterator ir_first, ir_last; - //-------------------- CONSTRUCTORS --------------------------------- - -public: - - AFSR_vertex_base_3() - : VertexBase(), _mark(-1), - _post_mark(-1), - ie_first(interior_edges.end()), ie_last(interior_edges.end()), - ir_first(incidence_requests.end()), ir_last(incidence_requests.end()) - { - _incident_border = new Intern_successors_type(new Next_border_elt(), - new Next_border_elt()); - _incident_border->first->first = NULL; - _incident_border->second->first = NULL; - } - - AFSR_vertex_base_3(const Point & p) - : VertexBase(p), _mark(-1), - _post_mark(-1), - ie_first(interior_edges.end()), ie_last(interior_edges.end()), - ir_first(incidence_requests.end()), ir_last(incidence_requests.end()) - { - _incident_border = new Intern_successors_type(new Next_border_elt(), - new Next_border_elt()); - _incident_border->first->first = NULL; - _incident_border->second->first = NULL; - } - - AFSR_vertex_base_3(const Point & p, Cell_handle f) - : VertexBase(p, f), _mark(-1), - _post_mark(-1), - ie_first(interior_edges.end()), ie_last(interior_edges.end()), - ir_first(incidence_requests.end()), ir_last(incidence_requests.end()) - { - _incident_border = new Intern_successors_type(new Next_border_elt(), - new Next_border_elt()); - _incident_border->first->first = NULL; - _incident_border->second->first = NULL; - } - - AFSR_vertex_base_3(Cell_handle f) - : VertexBase(f), _mark(-1), - _post_mark(-1), - ie_first(interior_edges.end()), ie_last(interior_edges.end()), - ir_first(incidence_requests.end()), ir_last(incidence_requests.end()) - { - _incident_border = new Intern_successors_type(new Next_border_elt(), - new Next_border_elt()); - _incident_border->first->first = NULL; - _incident_border->second->first = NULL; - } - - AFSR_vertex_base_3(const AFSR_vertex_base_3& other) - : VertexBase(), _mark(-1), - _post_mark(-1), - ie_first(interior_edges.end()), ie_last(interior_edges.end()), - ir_first(incidence_requests.end()), ir_last(incidence_requests.end()) - { - _incident_border = new Intern_successors_type(new Next_border_elt(), - new Next_border_elt()); - _incident_border->first->first = NULL; - _incident_border->second->first = NULL; - } - //-------------------- DESTRUCTOR ----------------------------------- - - ~AFSR_vertex_base_3() - { - if (_incident_border != NULL) - { - delete _incident_border->first; - delete _incident_border->second; - delete _incident_border; - } - if(ir_first != incidence_requests.end()){ - assert(ir_last != incidence_requests.end()); - typename std::list< Incidence_request_elt >::iterator b(ir_first), e(ir_last); - e++; - incidence_requests.erase(b, e); - } - - if(ie_first != interior_edges.end()){ - assert(ie_last != interior_edges.end()); - typename std::list::iterator b(ie_first), e(ie_last); - e++; - interior_edges.erase(b, e); - } - } - - //-------------------- MEMBER FUNCTIONS ----------------------------- - - inline void re_init() - { - if (_incident_border != NULL) - { - delete _incident_border->first; - delete _incident_border->second; - delete _incident_border; - } - - if(ir_first != incidence_requests.end()){ - assert(ir_last != incidence_requests.end()); - typename std::list< Incidence_request_elt >::iterator b(ir_first), e(ir_last); - e++; - incidence_requests.erase(b, e); - ir_first = incidence_requests.end(); - ir_last = incidence_requests.end(); - } - - _incident_border = new Intern_successors_type(new Next_border_elt(), - new Next_border_elt()); - _incident_border->first->first = NULL; - _incident_border->second->first = NULL; - _mark = -1; - _post_mark = -1; - } - - //------------------------------------------------------------------- - - inline bool is_on_border(const int& i) const - { - if (_incident_border == NULL) return false; //vh is interior - if (_incident_border->first->first != NULL) - { - if (_incident_border->second->first != NULL) - return ((_incident_border->first->second.second == i)|| - (_incident_border->second->second.second == i)); - return (_incident_border->first->second.second == i); - } - return false; //vh is still exterior - } - - inline Next_border_elt* get_next_on_border(const int& i) const - { - if (_incident_border == NULL) return NULL; //vh is interior - if (_incident_border->first->first != NULL) - if (_incident_border->first->second.second == i) - return _incident_border->first; - if (_incident_border->second->first != NULL) - if (_incident_border->second->second.second == i) - return _incident_border->second; - return NULL; - } - - - inline void remove_border_edge(Vertex_handle v) - { - if (_incident_border != NULL) - { - if (_incident_border->second->first == v) - { - _incident_border->second->first = NULL; - set_interior_edge(v); - return; - } - if (_incident_border->first->first == v) - { - if (_incident_border->second->first != NULL) - { - Next_border_elt* tmp = _incident_border->first; - _incident_border->first = _incident_border->second; - _incident_border->second = tmp; - _incident_border->second->first = NULL; - set_interior_edge(v); - return; - } - else - { - _incident_border->first->first = NULL; - set_interior_edge(v); - return; - } - } - } - } - - inline bool is_border_edge(Vertex_handle v) const - { - if (_incident_border == NULL) return false; - return ((_incident_border->first->first == v)|| - (_incident_border->second->first == v)); - } - - inline Next_border_elt* get_border_elt(Vertex_handle v) const - { - if (_incident_border == NULL) return NULL; - if (_incident_border->first->first == v) return _incident_border->first; - if (_incident_border->second->first == v) return _incident_border->second; - return NULL; - } - - inline Next_border_elt* first_incident() const - { - if (_incident_border == NULL) return NULL; - return _incident_border->first; - } - - inline Next_border_elt* second_incident() const - { - if (_incident_border == NULL) return NULL; - return _incident_border->second; - } - - - inline void set_next_border_elt(const Next_border_elt& elt) - { - if (_incident_border->first->first == NULL) - *_incident_border->first = elt; - else - { - if (_incident_border->second->first != NULL) - std::cerr << "+++probleme de MAJ du bord " << std::endl; - *_incident_border->second = elt; - } - } - - //------------------------------------------------------------------- - // pour gerer certaines aretes interieures: a savoir celle encore connectee au - // bord (en fait seule, les aretes interieures reliant 2 bords nous - // interressent...) - - inline bool is_interior_edge(Vertex_handle v) const - { - - bool r1; - if(ie_first == interior_edges.end()){ - r1 = false; - }else { - typename std::list::iterator b(ie_first), e(ie_last); - e++; - typename std::list::iterator r = std::find(b, e, v); - r1 = ( r != e); - } - - return r1; - } - - inline void set_interior_edge(Vertex_handle v) - { - if(ie_last == interior_edges.end()){ // empty set - assert(ie_first == ie_last); - ie_last = interior_edges.insert(ie_last, v); - ie_first = ie_last; - } else { - typename std::list::iterator e(ie_last); - e++; -#ifdef DEBUG - typename std::list::iterator r = std::find(ie_first, e, v); -#endif - assert(r == e); - ie_last = interior_edges.insert(e, v); - } - } - - inline void remove_interior_edge(Vertex_handle v) - { - if(ie_first == interior_edges.end()){ - assert(ie_last == ie_first); - } else if(ie_first == ie_last){ // there is only one element - if(*ie_first == v){ - interior_edges.erase(ie_first); - ie_last = interior_edges.end(); - ie_first = ie_last; - } - } else { - typename std::list::iterator b(ie_first), e(ie_last); - e++; - typename std::list::iterator r = std::find(b, e, v); - if(r != e){ - if(r == ie_first){ - ie_first++; - } - if(r == ie_last){ - ie_last--; - } - interior_edges.erase(r); - } - } - } - - //------------------------------------------------------------------- - - inline void set_incidence_request(const Incidence_request_elt& ir) - { - if(ir_last == incidence_requests.end()){ - assert(ir_first == ir_last); - ir_last = incidence_requests.insert(ir_last, ir); - ir_first = ir_last; - } else { - typename std::list::iterator e(ir_last); - e++; - ir_last = incidence_requests.insert(e, ir); - } - } - - inline bool is_incidence_requested() const - { - if(ir_last == incidence_requests.end()){ - assert(ir_first == incidence_requests.end()); - } - return (ir_last != incidence_requests.end()); - } - - inline Incidence_request_iterator incidence_request_begin() - { - return ir_first; - } - - inline Incidence_request_iterator get_incidence_request_end() - { - if(ir_last != incidence_requests.end()){ - assert(ir_first != incidence_requests.end()); - Incidence_request_iterator it(ir_last); - it++; - return it; - } - return ir_last; - } - - inline void erase_incidence_request() - { - if(ir_last != incidence_requests.end()){ - assert(ir_first != incidence_requests.end()); - ir_last++; - incidence_requests.erase(ir_first, ir_last); - ir_first = incidence_requests.end(); - ir_last = incidence_requests.end(); - } - } - - - //------------------------------------------------------------------- - - inline bool is_on_border() const - { - return (_mark > 0); - } - - inline bool not_interior() const - { - return (_mark != 0); - } - - inline int number_of_incident_border() const - { - return _mark; - } - - inline bool is_exterior() const - { - return (_mark < 0); - } - - //------------------------------------------------------------------- - - inline void inc_mark() - { - if (_mark==-1) - _mark=1; - else - _mark++; - } - - inline void dec_mark() - { - _mark--; - if(_mark == 0) - { - delete _incident_border->first; - delete _incident_border->second; - delete _incident_border; - _incident_border = NULL; - erase_incidence_request(); - } - } - - //------------------------------------------------------------------- - - inline void set_post_mark(const int& i) - { - _post_mark = i; - } - - inline bool is_post_marked(const int& i) - { - return (_post_mark == i); - } -}; - -template -std::list::Vertex_handle> AFSR_vertex_base_3::interior_edges; - -template -std::list::Incidence_request_elt> AFSR_vertex_base_3::incidence_requests; - -} // namespace CGAL - -#endif //CGAL_AFSR_VERTEX_BASE_3_H - diff --git a/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h b/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h index a2865382f2f..4bf12fc04e7 100644 --- a/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h +++ b/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h @@ -2405,6 +2405,35 @@ advancing_front_surface_reconstructionP(PointIterator b, AFSR::construct_polyhedron(polyhedron, R); } +template +void +advancing_front_surface_reconstructionP(PointIterator b, + PointIterator e, + Polyhedron_3& polyhedron, + double radius_ratio_bound = 5, + double beta = 0.52) +{ + typedef Advancing_front_surface_reconstruction_vertex_base_3 LVb; + typedef Advancing_front_surface_reconstruction_cell_base_3 LCb; + + typedef Triangulation_data_structure_3 Tds; + typedef Delaunay_triangulation_3 Triangulation_3; + + typedef Advancing_front_surface_reconstruction Reconstruction; + typedef typename Kernel::Point_3 Point_3; + + Triangulation_3 dt( boost::make_transform_iterator(b, AFSR::Auto_count()), + boost::make_transform_iterator(e, AFSR::Auto_count() ) ); + + AFSR_options opt; + opt.K = radius_ratio_bound; + // TODO: What to do with beta??? + Reconstruction R(dt, opt); + R.run(opt); + AFSR::construct_polyhedron(polyhedron, R); +} + + } // namespace CGAL diff --git a/Advancing_front_surface_reconstruction/include/CGAL/IO/AFSR_vrml.h b/Advancing_front_surface_reconstruction/include/CGAL/IO/AFSR_vrml.h deleted file mode 100644 index a145d7f48fb..00000000000 --- a/Advancing_front_surface_reconstruction/include/CGAL/IO/AFSR_vrml.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) 2015 INRIA Sophia-Antipolis (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// -// Author(s) : Frank Da, David Cohen-Steiner, Andreas Fabri - -#ifndef CGAL_AFSR_VRML_H -#define CGAL_AFSR_VRML_H - -namespace CGAL { - -template < class Vb, class Fb> -void -afsr_vrml_output(const Triangulation_data_structure_2& tds, - std::ostream& os, double r, double g, double b, - typename Triangulation_data_structure_2::Vertex_handle v, bool skip_infinite) -{ - typedef typename Triangulation_data_structure_2::Vertex_handle Vertex_handle; - typedef typename Triangulation_data_structure_2::Vertex_iterator Vertex_iterator; - typedef typename Triangulation_data_structure_2::Face_iterator Face_iterator; - - // ouput to a vrml file style - // Point are assumed to be 3d points with a stream operator << - // if non NULL, v is the vertex to be output first - // if skip_inf is true, the point in the first vertex is not output - // and the faces incident to v are not output - // (it may be for instance the infinite vertex of the terrain) - - os << "#VRML V2.0 utf8" << std::endl; - os << "Shape {\n" - << "appearance Appearance {\n" - << "material Material { diffuseColor " << r << " " << g << " " << b << "}}\n"; - os << "\tgeometry IndexedFaceSet {" << std::endl; - os << "\t\tcoord Coordinate {" << std::endl; - os << "\t\t\tpoint [" << std::endl; - - std::map vmap; - Vertex_iterator vit; - Face_iterator fit; - - int inum = 0; - for( vit= tds.vertices_begin(); vit != tds.vertices_end() ; ++vit) { - if ( v != vit) { - vmap[vit] = inum++; - os << "\t\t\t\t" << *vit << ","<< std::endl; - } - } - - os << "\t\t\t]" << std::endl; - os << "\t\t}" << std::endl; - os << "\t\tsolid FALSE\n" - "\t\tcoordIndex [" << std::endl; - - // faces - for(fit= tds.faces_begin(); fit != tds.faces_end(); ++fit) { - if (!skip_infinite || !fit->has_vertex(v)) { - os << "\t\t\t"; - os << vmap[(*fit).vertex(0)] << ", "; - os << vmap[(*fit).vertex(1)] << ", "; - os << vmap[(*fit).vertex(2)] << ", "; - os << "-1, " << std::endl; - } - } - os << "\t\t]" << std::endl; - os << "\t}" << std::endl; - os << "}" << std::endl; - return; -} - - -} // namespace CGAL - -#endif - diff --git a/Advancing_front_surface_reconstruction/include/CGAL/IO/Advancing_front_surface_reconstruction.h b/Advancing_front_surface_reconstruction/include/CGAL/IO/Advancing_front_surface_reconstruction.h deleted file mode 100644 index 799310651f7..00000000000 --- a/Advancing_front_surface_reconstruction/include/CGAL/IO/Advancing_front_surface_reconstruction.h +++ /dev/null @@ -1,1056 +0,0 @@ -// Copyright (c) 2015 INRIA Sophia-Antipolis (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// You can redistribute it and/or modify it under the terms of the GNU -// General Public License as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// -// Author(s) : Frank Da, David Cohen-Steiner, Andreas Fabri - -#ifndef CGAL_IO_ADVANCING_FRONT_SURFACE_RECONSTRUCTION_H -#define CGAL_IO_ADVANCING_FRONT_SURFACE_RECONSTRUCTION_H - - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace CGAL { - - -template -struct Is_not_exterior { - bool operator()(const Vertex& v)const { - return ! v.is_exterior(); - } -}; - -template -void -write_to_file_medit(char* foutput, const Surface& S) -{ - typedef typename Surface::Triangulation_3 Triangulation_3; - typedef typename Surface::Finite_vertices_iterator Finite_vertices_iterator; - typedef typename Surface::Finite_facets_iterator Finite_facets_iterator; - typedef typename Surface::Vertex_handle Vertex_handle; - typedef typename Surface::Vertex Vertex; - typedef typename Surface::Cell_handle Cell_handle; - - Triangulation_3& T = S.triangulation_3(); - - char foutput_points[100]; - char foutput_faces[100]; - std::strcpy(foutput_points, foutput); - std::strcpy(foutput_faces, foutput); - strcat(foutput_points, ".points"); - strcat(foutput_faces, ".faces"); - std::ofstream os_points(foutput_points, std::ios::out); - std::ofstream os_faces(foutput_faces, std::ios::out); - if((os_points.fail())||(os_faces.fail())) - std::cerr << "+++unable to open file for output" << std::endl; - else - std::cout << ">> files for output : " << foutput_points - << ", " << foutput_faces << std::endl; - - os_points.clear(); - os_faces.clear(); - - CGAL::set_ascii_mode(os_points); - CGAL::set_ascii_mode(os_faces); - - // af: what is the relationship to _vh_number in Extract_surface - std::size_t _vh_number = std::count_if(T.finite_vertices_begin(), - T.finite_vertices_end(), - Is_not_exterior()); - - os_points << _vh_number << std::endl; - - CGAL::Unique_hash_map vertex_index_map(-1, T.number_of_vertices()); - - int count(0); - for (Finite_vertices_iterator v_it = T.finite_vertices_begin(); - v_it != T.finite_vertices_end(); - v_it++){ - typename CGAL::Unique_hash_map::Data& d = vertex_index_map[v_it]; - if ((!v_it->is_exterior()) && d == -1){ - d = count; - count++; - os_points << v_it->point() << " 0" << std::endl; - } - } - - os_faces << S.number_of_facets() << std::endl; - for(Finite_facets_iterator f_it = T.finite_facets_begin(); - f_it != T.finite_facets_end(); - f_it++) - { - Cell_handle n, c = (*f_it).first; - int ni, ci = (*f_it).second; - n = c->neighbor(ci); - ni = n->index(c); - int i1, i2 ,i3; - - if (c->is_selected_facet(ci)) - { - i1 = (ci+1) & 3; - i2 = (ci+2) & 3; - i3 = (ci+3) & 3; - os_faces << 3 << " "; - os_faces << vertex_index_map[c->vertex(i1)] + 1 << " "; - os_faces << vertex_index_map[c->vertex(i2)] + 1 << " "; - os_faces << vertex_index_map[c->vertex(i3)] + 1 << " "; - os_faces << " 0 0 0 0" << std::endl; - } - - if (n->is_selected_facet(ni)) - { - i1 = (ni+1) & 3; - i2 = (ni+2) & 3; - i3 = (ni+3) & 3; - os_faces << 3 << " "; - os_faces << vertex_index_map[n->vertex(i1)] + 1 << " "; - os_faces << vertex_index_map[n->vertex(i2)] + 1 << " "; - os_faces << vertex_index_map[n->vertex(i3)] + 1 << " "; - os_faces << " 0 0 0 0" << std::endl; - } - } - - std::cout << "-- medit result written." << std::endl; -} - -//--------------------------------------------------------------------- - -template -void -write_to_file_gv(char* foutput, const Surface& S) -{ - typedef typename Surface::Triangulation_3 Triangulation_3; - typedef typename Surface::Finite_vertices_iterator Finite_vertices_iterator; - typedef typename Surface::Finite_facets_iterator Finite_facets_iterator; - typedef typename Surface::Vertex_handle Vertex_handle; - typedef typename Surface::Vertex Vertex; - typedef typename Surface::Cell_handle Cell_handle; - Triangulation_3& T = S.triangulation_3(); - - char foutput_tmp[100]; - std::strcpy(foutput_tmp, foutput); - - strcat(foutput_tmp, ".off"); - std::ofstream os(foutput_tmp, std::ios::out); - - if(os.fail()) - std::cerr << "+++unable to open file for output" << std::endl; - else - std::cout << ">> file for output : " << foutput_tmp << std::endl; - - os.precision(17); - os.clear(); - - CGAL::set_ascii_mode(os); - - std::size_t _vh_number = std::count_if(T.finite_vertices_begin(), - T.finite_vertices_end(), - Is_not_exterior()); - // Header. - os << "OFF" << std::endl - << _vh_number << " " << S.number_of_facets() << " " << 0 << std::endl; - - CGAL::Unique_hash_map vertex_index_map(-1, T.number_of_vertices()); - - int count(0); - for (Finite_vertices_iterator v_it = T.finite_vertices_begin(); - v_it != T.finite_vertices_end(); - v_it++){ - typename CGAL::Unique_hash_map::Data& d = vertex_index_map[v_it]; - if ((!v_it->is_exterior()) && d == -1){ - d = count; - count++; - os << v_it->point() << " \n"; - } - } - - for(Finite_facets_iterator f_it = T.finite_facets_begin(); - f_it != T.finite_facets_end(); - f_it++) - { - Cell_handle n, c = (*f_it).first; - int ni, ci = (*f_it).second; - n = c->neighbor(ci); - ni = n->index(c); - int i1, i2 ,i3; - - if (c->is_selected_facet(ci)) - { - i1 = (ci+1) & 3; - i2 = (ci+2) & 3; - i3 = (ci+3) & 3; - os << 3 << " "; - os << vertex_index_map[c->vertex(i1)] << " "; - os << vertex_index_map[c->vertex(i2)] << " "; - os << vertex_index_map[c->vertex(i3)] << "\n"; - } - - if (n->is_selected_facet(ni)) - { - i1 = (ni+1) & 3; - i2 = (ni+2) & 3; - i3 = (ni+3) & 3; - os << 3 << " "; - os << vertex_index_map[n->vertex(i1)] << " "; - os << vertex_index_map[n->vertex(i2)] << " "; - os << vertex_index_map[n->vertex(i3)] << "\n"; - } - } - - std::cout << "-- oogl result written." << std::endl; -} - - /* -template -OutputIterator -write_triple_indices(OutputIterator out, const Surface& S) -{ - std::cerr << "write triple indices" << std::endl; -#if 1 - typedef typename Surface::TDS_2 TDS_2; - typedef typename TDS_2::Face_iterator Face_iterator; - typedef typename Surface::Cell_handle Cell_handle; - - const TDS_2& tds = S.tds_2(); - - for(Face_iterator fit = tds.faces_begin(); fit != tds.faces_end(); ++fit){ - - if(fit->is_on_surface()){ - *out++ = CGAL::Triple(fit->vertex(0)->vertex_3()->id(), - fit->vertex(1)->vertex_3()->id(), - fit->vertex(2)->vertex_3()->id()); - } - } - return out; - -#else - typedef typename Surface::Triangulation_3 Triangulation_3; - typedef typename Surface::Finite_vertices_iterator Finite_vertices_iterator; - typedef typename Surface::Finite_facets_iterator Finite_facets_iterator; - typedef typename Surface::Vertex_handle Vertex_handle; - typedef typename Surface::Vertex Vertex; - typedef typename Surface::Cell_handle Cell_handle; - Triangulation_3& T = S.triangulation_3(); - - - for(Finite_facets_iterator f_it = T.finite_facets_begin(); - f_it != T.finite_facets_end(); - f_it++) - { - Cell_handle n, c = (*f_it).first; - int ni, ci = (*f_it).second; - n = c->neighbor(ci); - ni = n->index(c); - int i1, i2 ,i3; - - if (c->is_selected_facet(ci)) - { - i1 = (ci+1) & 3; - i2 = (ci+2) & 3; - i3 = (ci+3) & 3; - *out++ = CGAL::Triple(c->vertex(i1)->id(), - c->vertex(i2)->id(), - c->vertex(i3)->id()); - } - - if (n->is_selected_facet(ni)) - { - i1 = (ni+1) & 3; - i2 = (ni+2) & 3; - i3 = (ni+3) & 3; - - *out++ = CGAL::Triple(n->vertex(i1)->id(), - n->vertex(i2)->id(), - n->vertex(i3)->id()); - } - } - return out; -#endif -} -*/ - - -//--------------------------------------------------------------------- -template -void -write_to_file_ply(char* foutput, const Surface& S) -{ - typedef typename Surface::Triangulation_3 Triangulation_3; - typedef typename Surface::Finite_vertices_iterator Finite_vertices_iterator; - typedef typename Surface::Finite_facets_iterator Finite_facets_iterator; - typedef typename Surface::Vertex_handle Vertex_handle; - typedef typename Surface::Cell_handle Cell_handle; - Triangulation_3& T = S.triangulation_3(); - char foutput_tmp[100]; - std::strcpy(foutput_tmp, foutput); - - strcat(foutput_tmp, ".ply"); - std::ofstream os(foutput_tmp, std::ios::out | std::ios::binary); - - if(os.fail()) - std::cerr << "+++unable to open file for output" << std::endl; - else - std::cout << ">> file for output : " << foutput_tmp << std::endl; - - os.clear(); - - CGAL::set_ascii_mode(os); - - // Header. - os << "ply" << std::endl - << "format binary_little_endian 1.0" << std::endl - << "comment generated by ply_writer" << std::endl - << "element vertex " << S.number_of_vertices() << std::endl - << "property float x" << std::endl - << "property float y" << std::endl - << "property float z" << std::endl - << "element face " << S.number_of_facets() << std::endl - << "property list uchar int vertex_indices" << std::endl - << "end_header" << std::endl; - - CGAL::set_binary_mode(os); - - CGAL::Unique_hash_map vertex_index_map(-1, T.number_of_vertices()); - - int count(0); - for (Finite_vertices_iterator v_it = T.finite_vertices_begin(); - v_it != T.finite_vertices_end(); - v_it++){ - typename CGAL::Unique_hash_map::Data& d = vertex_index_map[v_it]; - if ((!v_it->is_exterior()) && d == -1){ - d = count; - count++; - os << v_it->point() << std::endl; - } - } - - for(Finite_facets_iterator f_it = T.finite_facets_begin(); - f_it != T.finite_facets_end(); - f_it++) - { - Cell_handle n, c = (*f_it).first; - int ni, ci = (*f_it).second; - n = c->neighbor(ci); - ni = n->index(c); - int i1, i2 ,i3; - - if (c->is_selected_facet(ci)) - { - i1 = (ci+1) & 3; - i2 = (ci+2) & 3; - i3 = (ci+3) & 3; - char three = '3'; - CGAL::write(os, three, CGAL::io_Read_write()); - CGAL::write(os,vertex_index_map[c->vertex(i1)], CGAL::io_Read_write()); - CGAL::write(os,vertex_index_map[c->vertex(i2)], CGAL::io_Read_write()); - CGAL::write(os,vertex_index_map[c->vertex(i3)], CGAL::io_Read_write()); - os << std::endl; // without color. - // os << 4 << drand48() << drand48() << drand48() << 1.0; // random - // color - } - - if (n->is_selected_facet(ni)) - { - i1 = (ni+1) & 3; - i2 = (ni+2) & 3; - i3 = (ni+3) & 3; - char three = '3'; - CGAL::write(os, three, CGAL::io_Read_write()); - CGAL::write(os,vertex_index_map[n->vertex(i1)], CGAL::io_Read_write()); - CGAL::write(os,vertex_index_map[n->vertex(i2)], CGAL::io_Read_write()); - CGAL::write(os,vertex_index_map[n->vertex(i3)], CGAL::io_Read_write()); - os << std::endl; // without color. - // os << 4 << drand48() << drand48() << drand48() << 1.0; // random - // color - } - } - - //std::cout << "-- ply result written." << std::endl; -} - -//--------------------------------------------------------------------- -template -void -write_to_file_iv_border_edges(const Surface& S, std::ofstream& os) -{ - typedef typename Surface::Triangulation_3 Triangulation_3; - typedef typename Surface::Finite_vertices_iterator Finite_vertices_iterator; - typedef typename Surface::Finite_edges_iterator Finite_edges_iterator; - typedef typename Surface::Vertex_handle Vertex_handle; - typedef typename Surface::Cell_handle Cell_handle; - typedef typename Surface::Edge_like Edge_like; - typedef typename Surface::Border_elt Border_elt; - - Triangulation_3& T = S.triangulation_3(); - typedef std::pair indiced_vh; - std::map _vh_vect; - int _vh_bord_count = 0; - - for (Finite_vertices_iterator v_it = T.finite_vertices_begin(); - v_it != T.finite_vertices_end(); - v_it++) - if (v_it->is_on_border()) - { - _vh_vect.insert(indiced_vh (v_it, _vh_bord_count)); - _vh_bord_count++; - } - - typedef const typename Triangulation_3::Point* Const_point_star; - std::vector points_tab(_vh_bord_count); - for (typename std::map::iterator vh_it = _vh_vect.begin(); - vh_it != _vh_vect.end(); vh_it++) - points_tab[vh_it->second] = &vh_it->first->point(); - - os << " Separator {" << std::endl << -" Switch {" << std::endl << -" whichChild 0" << std::endl << -" Separator {" << std::endl << -" BaseColor {" << std::endl << -" rgb 1 0 0" << std::endl << -" }" << std::endl << -" Coordinate3 {" << std::endl << -" point [ "; - bool first(true); - for(int vh_i=0; vh_i<_vh_bord_count; vh_i++) - { - if (!first) os << "," << std::endl << -" "; - else - first=false; - os << *points_tab[vh_i]; - } - os << " ]" << std::endl << -" }" << std::endl << -" IndexedLineSet {" << std::endl << -" coordIndex [ "; - - first=true; - for(Finite_edges_iterator e_it=T.finite_edges_begin(); - e_it!=T.finite_edges_end(); - e_it++) - { - Cell_handle c = (*e_it).first; - int i1 = (*e_it).second, i2 = (*e_it).third; - Edge_like key(c->vertex(i1), c->vertex(i2)); - Border_elt result; - - if (S.is_border_elt(key, result)) - { - if (!first) - os << "," << std::endl << " "; - else - first=false; - os << _vh_vect.find(c->vertex(i1))->second << ", "; - os << _vh_vect.find(c->vertex(i2))->second << ", "; - os << -1; - } - } - os << " ]" << std::endl << -" }}" << std::endl << -" }}" << std::endl; -} - -//--------------------------------------------------------------------- -template -void -write_to_file_iv_remaining_points(const Surface& S, std::ofstream& os) -{ - typedef typename Surface::Triangulation_3 Triangulation_3; - typedef typename Surface::Finite_vertices_iterator Finite_vertices_iterator; - typedef typename Surface::Vertex_handle Vertex_handle; - typedef typename Surface::Cell_handle Cell_handle; - Triangulation_3& T = S.triangulation_3(); - typedef std::pair indiced_vh; - std::map _vh_vect; - int _vh_bord_count(0); - - for (Finite_vertices_iterator v_it = T.finite_vertices_begin(); - v_it != T.finite_vertices_end(); - v_it++) - if (v_it->is_exterior()) - { - _vh_vect.insert(indiced_vh (v_it, _vh_bord_count)); - _vh_bord_count++; - } - - typedef const typename Triangulation_3::Point* Const_point_star; - std::vector points_tab(_vh_bord_count); - for (typename std::map::iterator vh_it = _vh_vect.begin(); - vh_it != _vh_vect.end(); vh_it++) - points_tab[vh_it->second] = &vh_it->first->point(); - - os << " Separator {" << std::endl << -" Switch {" << std::endl << -" whichChild 0" << std::endl << -" Separator {" << std::endl << -" BaseColor {" << std::endl << -" rgb 0 0 1" << std::endl << -" }" << std::endl << -" Coordinate3 {" << std::endl << -" point [ "; - bool first(true); - for(int vh_i=0; vh_i<_vh_bord_count; vh_i++) - { - if (!first) os << "," << std::endl << -" "; - else - first=false; - os << *points_tab[vh_i]; - } - os << " ]" << std::endl << -" }" << std::endl << -" PointSet {" << std::endl << -" startIndex 0" << std::endl << -" numPoints -1" << std::endl << -" }"; - - os << " }" << std::endl << -" }}" << std::endl; - -} - -//--------------------------------------------------------------------- -// attention cette procedure produit un fichier tres sale... trop de sommets... - -// !!!! bizarre : ca a l'air de buggue pour hand.xyz (seg fault...) -template -void -write_to_file_iv_border_facets(const Surface& S, std::ofstream& os) -{ - typedef typename Surface::Triangulation_3 Triangulation_3; - typedef typename Surface::Finite_vertices_iterator Finite_vertices_iterator; - typedef typename Surface::Finite_facets_iterator Finite_facets_iterator; - typedef typename Surface::Vertex_handle Vertex_handle; - typedef typename Surface::Cell_handle Cell_handle; - typedef typename Surface::Edge_like Edge_like; - typedef typename Surface::Border_elt Border_elt; - - Triangulation_3& T = S.triangulation_3(); - typedef std::pair indiced_vh; - std::map _vh_vect; - int _vh_bord_count(0); - - for (Finite_vertices_iterator v_it = T.finite_vertices_begin(); - v_it != T.finite_vertices_end(); - v_it++) -// if (v_it->number_of_incident_border() > 0) - { - _vh_vect.insert(indiced_vh (v_it, _vh_bord_count)); - _vh_bord_count++; - } - - typedef const typename Triangulation_3::PoinPoint* Const_point_star; - std::vector points_tab(_vh_bord_count); - for (typename std::map::iterator vh_it = _vh_vect.begin(); - vh_it != _vh_vect.end(); vh_it++) - points_tab[vh_it->second] = &vh_it->first->point(); - - os << " Separator {" << std::endl << -" Switch {" << std::endl << -" whichChild 0" << std::endl << -" Separator {" << std::endl << -" ShapeHints {" << std::endl << -" vertexOrdering CLOCKWISE" << std::endl << -" shapeType UNKNOWN_SHAPE_TYPE" << std::endl << -" faceType CONVEX" << std::endl << -" creaseAngle 1.0" << std::endl << -" }" << std::endl << -" BaseColor {" << std::endl << -" rgb 0 0 1" << std::endl << -" }" << std::endl << -" Coordinate3 {" << std::endl << -" point [ "; - bool first(true); - for(int vh_i=0; vh_i<_vh_bord_count; vh_i++) - { - if (!first) os << "," << std::endl << -" "; - else - first=false; - os << *points_tab[vh_i]; - } - os << " ]" << std::endl << -" }" << std::endl << -" IndexedFaceSet {" << std::endl << -" coordIndex [ "; - - first=true; - for(Finite_facets_iterator f_it=T.finite_facets_begin(); - f_it!=T.finite_facets_end(); - f_it++) - { - Cell_handle c = (*f_it).first; - int index = (*f_it).second; - int i1 = (index+1) & 3; - int i2 = (index+2) & 3; - int i3 = (index+3) & 3; - Edge_like key12(c->vertex(i1), c->vertex(i2)); - Edge_like key13(c->vertex(i1), c->vertex(i3)); - Edge_like key32(c->vertex(i3), c->vertex(i2)); - Border_elt result; - - // les trois aretes sur le bord... -// if (is_border_elt(key12, result)&& -// is_border_elt(key13, result)&& -// is_border_elt(key32, result)) - - // au moins 2 aretes sur le bord... -// if (((is_border_elt(key12, result)&& -// is_border_elt(key13, result)))|| -// ((is_border_elt(key32, result)&& -// is_border_elt(key13, result)))|| -// ((is_border_elt(key12, result)&& -// is_border_elt(key32, result)))) - - // une arete sur le bord... - if ((is_border_elt(key12, result)|| - is_border_elt(key13, result)|| - is_border_elt(key32, result))&& - (c->is_selected_facet(index)|| - c->neighbor(index)->is_selected_facet(c->neighbor(index)->index(c)))) - - // au moins 2 aretes sur le bord... -// if (((is_border_elt(key12, result)&& -// is_border_elt(key13, result)))|| -// ((is_border_elt(key32, result)&& -// is_border_elt(key13, result)))|| -// ((is_border_elt(key12, result)&& -// is_border_elt(key32, result)))) - { - if (!first) - os << "," << std::endl << " "; - else - first=false; - os << _vh_vect.find(c->vertex(i1))->second << ", "; - os << _vh_vect.find(c->vertex(i2))->second << ", "; - os << _vh_vect.find(c->vertex(i3))->second << ", "; - - os << -1; - } - } - os << " ]" << std::endl << -" }}" << std::endl << -" }}" << std::endl; -} - -//--------------------------------------------------------------------- -template -void -write_to_file_iv(char* foutput, const Surface& S, - const bool& boundary) -{ - typedef typename Surface::Triangulation_3 Triangulation_3; - typedef typename Surface::Finite_vertices_iterator Finite_vertices_iterator; - typedef typename Surface::Finite_facets_iterator Finite_facets_iterator; - typedef typename Surface::Vertex_handle Vertex_handle; - typedef typename Surface::Cell_handle Cell_handle; - Triangulation_3& T = S.triangulation_3(); - char foutput_tmp[100]; - std::strcpy(foutput_tmp, foutput); - - strcat(foutput_tmp, ".iv"); - std::ofstream os(foutput_tmp, std::ios::out); - - if(os.fail()) - std::cerr << "+++unable to open file for output" << std::endl; - else - std::cout << ">> file for output : " << foutput_tmp << std::endl; - - os.precision(17); - os.clear(); - - CGAL::set_ascii_mode(os); - - // Header. - os << -"#Inventor V2.1 ascii" << std::endl << -"Separator {" << std::endl << -" PerspectiveCamera {" << std::endl << -" position 0 0 2.41421" << std::endl << -" nearDistance 1.41421" << std::endl << -" farDistance 3.41421" << std::endl << -" focalDistance 2.41421" << std::endl << -" }" << std::endl << -" Group {" << std::endl << -" Rotation {" << std::endl << -" }" << std::endl << -" DirectionalLight {" << std::endl << -" direction 0.2 -0.2 -0.979796" << std::endl << -" }" << std::endl << -" ResetTransform {" << std::endl << -" } }" << std::endl << -" Separator {" << std::endl << -" Switch {" << std::endl << -" whichChild 0" << std::endl << -" Separator {" << std::endl << -" ShapeHints {" << std::endl << -" vertexOrdering CLOCKWISE" << std::endl << -" shapeType UNKNOWN_SHAPE_TYPE" << std::endl << -" faceType CONVEX" << std::endl << -" creaseAngle 1.0" << std::endl << -" }" << std::endl << -" BaseColor {" << std::endl << -" rgb 0.6 0.6 0.48" << std::endl << -" }" << std::endl << -" Coordinate3 {" << std::endl << -" point [ "; - - CGAL::Unique_hash_map vertex_index_map(-1, T.number_of_vertices()); - - int count(0); - for (Finite_vertices_iterator v_it = T.finite_vertices_begin(); - v_it != T.finite_vertices_end(); - v_it++){ - typename CGAL::Unique_hash_map::Data& d = vertex_index_map[v_it]; - if ((!v_it->is_exterior()) && d == -1){ - d = count; - count++; - os << v_it->point() << " ,\n"; - } - } - os << " ]" << std::endl << -" }" << std::endl << -" IndexedFaceSet {" << std::endl << -" coordIndex [ "; - - for(Finite_facets_iterator f_it = T.finite_facets_begin(); - f_it != T.finite_facets_end(); - f_it++) - { - Cell_handle n, c = (*f_it).first; - int ni, ci = (*f_it).second; - n = c->neighbor(ci); - ni = n->index(c); - int i1, i2 ,i3; - - if (c->is_selected_facet(ci)) - { - - i1 = (ci+1) & 3; - i2 = (ci+2) & 3; - i3 = (ci+3) & 3; - os << vertex_index_map[c->vertex(i1)] << ", "; - os << vertex_index_map[c->vertex(i2)] << ", "; - os << vertex_index_map[c->vertex(i3)] << ", "; - os << -1; - } - - if (n->is_selected_facet(ni)) - { - i1 = (ni+1) & 3; - i2 = (ni+2) & 3; - i3 = (ni+3) & 3; - os << vertex_index_map[n->vertex(i1)] << ", "; - os << vertex_index_map[n->vertex(i2)] << ", "; - os << vertex_index_map[n->vertex(i3)] << ", "; - os << -1; - } - } - - - os << " ]\n" - " }\n" - " }}\n" - " }\n"; - - if (boundary) - { - // pour visualiser les boundaries restant a la fin... - write_to_file_iv_border_edges(S, os); - - // pour visualiser les facettes eventuellement candidates... - // write_to_file_iv_border_facets(S, os); - - // pour afficher les points non selectionnes, ~bruit??? - // write_to_file_iv_remaining_points(S, os); - } - - os << "}" << std::endl; - - std::cout << "-- Inventor result written." << std::endl; -} - - -template -void -write_boundaries(std::ostream& os, const Surface& S) -{ - - typedef typename Surface::Triangulation_3 Triangulation_3; - typedef typename Surface::Finite_vertices_iterator Finite_vertices_iterator; - typedef typename Surface::Boundary_iterator Boundary_iterator; - typedef typename Surface::Vertex_handle Vertex_handle; - typedef typename Surface::Vertex Vertex; - typedef typename Surface::Cell_handle Cell_handle; - - - CGAL::Random random; - for(Boundary_iterator it = S.boundaries_begin(); - it != S.boundaries_end(); - ++it) { - double blue = random.get_double(0,1); - os << - "Shape {\n" - "appearance Appearance {\n" - "material Material { emissiveColor 1 0 " << blue << "}}\n" - "geometry\n" - "IndexedLineSet {\n" - "coord Coordinate {\n" - "point [ " << std::endl; - unsigned int count = 0; - Vertex_handle first = *it; - do { - os << (*it)->point() << std::endl; - ++it; - count++; - } while(*it != first); - os << "]\n" - "}\n" - "coordIndex [\n"; - - for(unsigned int i = 0; i < count; i++){ - os << i << ", "; - } - os << "0, -1\n"; - os << "]\n" - "}#IndexedLineSet\n" - "}# Shape\n"; - } -} - - - - -template -void -write_to_file_vrml2(char* foutput, const Surface& S, - const bool& boundary, double red, double green, double blue, bool no_header) -{ - - typedef typename Surface::Triangulation_3 Triangulation_3; - typedef typename Surface::Finite_vertices_iterator Finite_vertices_iterator; - typedef typename Surface::Finite_facets_iterator Finite_facets_iterator; - typedef typename Surface::Vertex_handle Vertex_handle; - typedef typename Surface::Cell_handle Cell_handle; - //Triangulation_3& T = S.triangulation_3(); - - typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; - - typedef CGAL::Triangulation_data_structure_2 > TDS; - - TDS tds; - - TDS::Vertex_handle inf = AFSR::orient(tds, S); - - char foutput_tmp[100]; - std::strcpy(foutput_tmp, foutput); - - strcat(foutput_tmp, ".wrl"); - std::ofstream os(foutput_tmp, std::ios::out); - - if(os.fail()) - std::cerr << "+++unable to open file for output" << std::endl; - else - std::cout << ">> file for output : " << foutput_tmp << std::endl; - - os.precision(17); - os.clear(); - - CGAL::set_ascii_mode(os); - - if(! no_header){ - // Header. - os << - "#VRML V2.0 utf8\n" - "Background {skyColor .1 .5 .5}\n" - "Group {\n" - "children [\n" << std::endl; - }; - - afsr_vrml_output(tds, os, red, green, blue, inf, true); - - if (boundary){ - write_boundaries(os, S); - } - - typename Surface::Outlier_iterator pit = S.outliers_begin(); - - if(S.number_of_outliers()!= 0) { - os << "Shape {\n" - "geometry PointSet {\n" - "coord Coordinate { point [\n"; - - BOOST_FOREACH(const typename Surface::Point& p , S.outliers()){ - os << p.x() << " " << p.y() << " " << p.z() << ",\n"; - } - os << "] } }\n" - "appearance Appearance {\n" - " material Material {\n" - " emissiveColor 1 0.1 0\n" - " }\n" - "}\n" - "} # Shape\n"; - } - - if(! no_header){ - os << "] # children\n" - "} # Group\n"; - } - std::cout << "-- wrl result written." << std::endl; -} - - - -template -void -write_to_file_stl(char* foutput, const Surface& S) -{ - - typedef typename Surface::Triangulation_3 Triangulation_3; - typedef typename Surface::Finite_vertices_iterator Finite_vertices_iterator; - typedef typename Surface::Finite_facets_iterator Finite_facets_iterator; - typedef typename Surface::Vertex_handle Vertex_handle; - typedef typename Surface::Cell_handle Cell_handle; - typedef typename Triangulation_3::Point Point; - typedef typename CGAL::Kernel_traits::Kernel::Vector_3 Vector; - Triangulation_3& T = S.triangulation_3(); - - - char foutput_tmp[100]; - std::strcpy(foutput_tmp, foutput); - - strcat(foutput_tmp, ".stl"); - std::ofstream os(foutput_tmp, std::ios::out); - - if(os.fail()) - std::cerr << "+++unable to open file for output" << std::endl; - else - std::cout << ">> file for output : " << foutput_tmp << std::endl; - - os.precision(17); - os.clear(); - - CGAL::set_ascii_mode(os); - - // Header. - os << "solid" << std::endl; - - for(Finite_facets_iterator f_it = T.finite_facets_begin(); - f_it != T.finite_facets_end(); - f_it++) - { - Cell_handle n, c = (*f_it).first; - int ni, ci = (*f_it).second; - - bool selected = false; - if(c->is_selected_facet(ci)){ - selected = true; - } else { - n = c->neighbor(ci); - ni = n->index(c); - if(n->is_selected_facet(ni)) { - selected = true; - c = n; - ci = ni; - } - } - - if(selected){ - int i1, i2 ,i3; - - i1 = (ci+1) & 3; - i2 = (ci+2) & 3; - i3 = (ci+3) & 3; - - Point p = c->vertex(i1)->point(); - Point q = c->vertex(i2)->point(); - Point r = c->vertex(i3)->point(); - // compute normal - Vector n = CGAL::cross_product( q-p, r-p); - Vector norm = n / sqrt( n * n); - os << "outer loop" << std::endl; - os << "facet normal " << norm << std::endl; - os << "vertex " << p << std::endl; - os << "vertex " << q << std::endl; - os << "vertex " << r << std::endl; - os << "endloop\nendfacet" << std::endl; - } - - } - - os << "endsolid" << std::endl; - - std::cout << "-- stl result written." << std::endl; -} - - -//--------------------------------------------------------------------- -template -void -write_to_file(char* foutput, const Surface& S, - const bool& boundary, const int& out_format, - double red, double green, double blue, bool no_header) -{ - switch(out_format) - { - case -2: - // no output file... - return; - case -1: - write_to_file_iv(foutput, S, boundary); - write_to_file_vrml2(foutput, S, boundary, red, green, blue, no_header); - write_to_file_gv(foutput, S); - write_to_file_medit(foutput, S); - //write_to_file_ply(foutput, S); - return; - case 0: - write_to_file_vrml2(foutput, S, boundary, red, green, blue, no_header); - return; - case 1: - write_to_file_gv(foutput, S); - return; - case 2: - write_to_file_medit(foutput, S); - return; - case 3: - write_to_file_ply(foutput, S); - return; - case 4: - write_to_file_iv(foutput, S, boundary); - return; - case 5: - write_to_file_stl(foutput, S); - return; - } -} - -} // namespace CGAL - - -#endif // CGAL_IO_ADVANCING_FRONT_SURFACE_RECONSTRUCTION_H diff --git a/Advancing_front_surface_reconstruction/include/CGAL/Tvb_3_2.h b/Advancing_front_surface_reconstruction/include/CGAL/Tvb_3_2.h deleted file mode 100644 index 8fbb59d7739..00000000000 --- a/Advancing_front_surface_reconstruction/include/CGAL/Tvb_3_2.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 1997 INRIA Sophia-Antipolis (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org); you may redistribute it under -// the terms of the Q Public License version 1.0. -// See the file LICENSE.QPL distributed with CGAL. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $Source: /CVSROOT/CGAL/Packages/Triangulation_2/include/CGAL/Triangulation_vertex_base_2.h,v $ -// $Revision$ $Date$ -// $Name: current_submission $ -// -// Author(s) : Mariette Yvinec - - -#ifndef CGAL_TVB_3_2_H -#define CGAL_TVB_3_2_H - -#include -#include - -namespace CGAL { - -template < typename GT, - typename Vb = Triangulation_ds_vertex_base_2<> > -class Tvb_3_2 - : public Vb - -{ - typedef typename Vb::Triangulation_data_structure Tds; -public: - typedef GT Geom_traits; - typedef typename GT::Point_3 Point; - typedef Tds Triangulation_data_structure; - typedef typename Tds::Face_handle Face_handle; - typedef typename Tds::Vertex_handle Vertex_handle; - - template < typename TDS2 > - struct Rebind_TDS { - typedef typename Vb::template Rebind_TDS::Other Vb2; - typedef Tvb_3_2 Other; - }; - -private: - Point _p; - -public: - Tvb_3_2 () : Vb() {} - Tvb_3_2(const Point & p) : Vb(), _p(p) {} - Tvb_3_2(const Point & p, Face_handle f) - : Vb(f), _p(p) {} - Tvb_3_2(Face_handle f) : Vb(f) {} - - void set_point(const Point & p) { _p = p; } - const Point& point() const { return _p; } - - // the non const version of point() is undocument - // but needed to make the point iterator works - // using Lutz projection scheme - Point& point() { return _p; } - - //the following trivial is_valid to allow - // the user of derived face base classes - // to add their own purpose checking - bool is_valid(bool /* verbose */ = false, int /* level */ = 0) const - {return true;} -}; - -template < class GT, class Vb > -std::istream& -operator>>(std::istream &is, Tvb_3_2 &v) - // non combinatorial information. Default = point -{ - return is >> static_cast(v) >> v.point(); -} - -template < class GT, class Vb > -std::ostream& -operator<<(std::ostream &os, const Tvb_3_2 &v) - // non combinatorial information. Default = point -{ - return os << static_cast(v) << v.point(); -} - - - -} //namespace CGAL - -#endif //CGAL_TVB_3_2_H