/usr/include/CGAL/IO/File_poly.h is in libcgal-dev 4.7-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | // Copyright (c) 2004 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) : Laurent RINEAU
#ifndef CGAL_FILE_POLY_H
#define CGAL_FILE_POLY_H
namespace CGAL {
template <class CDT>
inline
void
read_triangle_poly_file(CDT& t, std::istream &f)
{
read_triangle_poly_file(t, f, Emptyset_iterator());
}
//the function that reads a Shewchuk Triangle .poly file
template <class CDT, class OutputIterator>
void
read_triangle_poly_file(CDT& t, std::istream &f,
OutputIterator seeds)
{
typedef typename CDT::Vertex_handle Vertex_handle;
typedef typename CDT::Point Point;
t.clear();
unsigned int number_of_points;
skip_comment_OFF(f);
f >> number_of_points;
skip_until_EOL(f);
skip_comment_OFF(f);
// read vertices
std::vector<Vertex_handle> vertices(number_of_points);
for(unsigned int i = 0; i < number_of_points; ++i)
{
unsigned int j;
double x, y;
f >> j >> iformat(x) >> iformat(y);
Point p(x, y);
skip_until_EOL(f); skip_comment_OFF(f);
vertices[--j] = t.insert(p);
}
// read segments
unsigned int number_of_segments;
f >> number_of_segments;
skip_until_EOL(f); skip_comment_OFF(f);
for(unsigned int k = 0; k < number_of_segments; ++k)
{
unsigned int l, v1, v2;
f >> l >> v1 >> v2;
skip_until_EOL(f); skip_comment_OFF(f);
t.insert_constraint(vertices[--v1], vertices[--v2]);
}
// read holes
unsigned int number_of_holes;
f >> number_of_holes;
for(unsigned int m = 0; m < number_of_holes; ++m)
{
unsigned int n;
Point p;
f >> n >> p;
skip_until_EOL(f); skip_comment_OFF(f);
*seeds++ = p;
}
}
//the function that write a Shewchuk Triangle .poly file
template <class CDT, typename InputIterator>
void
write_triangle_poly_file(const CDT& t, std::ostream &f,
InputIterator begin, InputIterator end)
{
typedef typename CDT::Vertex_handle Vertex_handle;
typedef typename CDT::Finite_vertices_iterator
Finite_vertices_iterator;
typedef typename CDT::Finite_edges_iterator
Finite_edges_iterator;
std::map<Vertex_handle, unsigned int> index;
// write vertices
f << "# Shewchuk Triangle .poly file, produced by the CGAL::Mesh_2 package"
<< std::endl
<< "# Neither attributes nor boundary markers are used." << std::endl
<< t.number_of_vertices() << " " << 2 << " "
<< 0 << " " << 0 << std::endl;
f << std::endl;
unsigned int vertices_counter = 0;
for(Finite_vertices_iterator vit = t.finite_vertices_begin();
vit != t.finite_vertices_end();
++vit)
{
f << ++vertices_counter << " " << vit->point() << std::endl;
index[vit] = vertices_counter;
}
f << std::endl;
// write constrained edges
int number_of_constrained_edges = 0;
for(Finite_edges_iterator it = t.finite_edges_begin();
it != t.finite_edges_end();
++it)
if(it->first->is_constrained(it->second))
++number_of_constrained_edges;
f << number_of_constrained_edges << " " << 0 << std::endl;
unsigned int edges_counter = 0;
for(Finite_edges_iterator eit = t.finite_edges_begin();
eit != t.finite_edges_end();
++eit)
if(eit->first->is_constrained(eit->second))
f << ++edges_counter << " "
<< index[eit->first->vertex(t.cw(eit->second))] << " "
<< index[eit->first->vertex(t.ccw(eit->second))]
<< std::endl;
f << std::endl;
// write seeds, assuming that the seeds unmarks faces
f << std::distance(begin, end) << std::endl;
unsigned int seeds_counter = 0;
for(InputIterator sit = begin;
sit!=end; ++sit)
f << ++seeds_counter << " " << *sit << std::endl;
}
//the same without holes.
template <class CDT>
void
write_triangle_poly_file(const CDT& t, std::ostream &f)
{
std::list<int> l;
write_triangle_poly_file(t, f, l.begin(), l.end());
}
} // end namespace CGAL
#endif // CGAL_FILE_POLY_H
|