mirror of https://github.com/CGAL/cgal
New data for 2D and 3D + improved export
This commit is contained in:
parent
ad12bb88df
commit
d8b0e2904e
|
|
@ -1,11 +1,11 @@
|
|||
2
|
||||
0.0071 1.6899 1.2 0
|
||||
0.0071 1.6899 0
|
||||
0.3272 1.3694 0.05
|
||||
1.3697 1.8296 0.1
|
||||
0.6722 0.3012 0.15
|
||||
1.1726 0.1899 0.2
|
||||
0.4374 2.8541 0.25
|
||||
0.4374 2.8541 100.25
|
||||
2.5923 0.1904 0.3
|
||||
1.3083 2.5462 0.35
|
||||
1.3083 2.5462 200.35
|
||||
1.4981 1.3929 0.4
|
||||
2.1304 2.055 0.45
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
3
|
||||
0.0071 1.6899 2.521 0
|
||||
0.3272 1.3694 3.15 100.05
|
||||
1.3697 1.8296 2.654 0.1
|
||||
0.6722 0.3012 0.1548 100.15
|
||||
1.1726 0.1899 0.3658 0.2
|
||||
0.4374 2.8541 1.45894 200.25
|
||||
2.5923 0.1904 0.6971 0.3
|
||||
1.3083 2.5462 1.3658 100.35
|
||||
1.4981 1.3929 2.949 0.4
|
||||
2.1304 2.055 0.6597455 1.45
|
||||
|
|
@ -9,22 +9,34 @@ typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K;
|
|||
typedef CGAL::Regular_triangulation_euclidean_traits<K> Traits;
|
||||
typedef CGAL::Regular_triangulation<Traits> RT;
|
||||
|
||||
int main()
|
||||
void test(int dim)
|
||||
{
|
||||
std::ifstream in("data/points.cin");
|
||||
std::stringstream input_filename;
|
||||
input_filename << "data/points_" << dim << ".cin";
|
||||
std::ifstream in(input_filename.str());
|
||||
|
||||
RT::Weighted_point wp;
|
||||
std::vector<RT::Weighted_point> wpoints;
|
||||
|
||||
int dim;
|
||||
in >> dim;
|
||||
int dim_from_file;
|
||||
in >> dim_from_file;
|
||||
while(in >> wp)
|
||||
wpoints.push_back(wp);
|
||||
|
||||
// Build the Regular Triangulation
|
||||
RT rt(dim);
|
||||
RT rt(dim_from_file);
|
||||
rt.insert(wpoints.begin(), wpoints.end());
|
||||
std::ofstream off_stream("data/rt.off");
|
||||
CGAL::export_triangulation_to_off(off_stream, rt);
|
||||
|
||||
// Export
|
||||
std::stringstream output_filename;
|
||||
output_filename << "data/rt_dim" << dim << ".off";
|
||||
std::ofstream off_stream(output_filename.str());
|
||||
CGAL::export_triangulation_to_off(off_stream, rt, false);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(2);
|
||||
test(3);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,8 @@ operator>>(std::istream &is, typename Wrap::Weighted_point_d<K> & wp)
|
|||
template < class GT, class TDS >
|
||||
std::ostream &
|
||||
export_triangulation_to_off(std::ostream & os,
|
||||
const Triangulation<GT,TDS> & tr)
|
||||
const Triangulation<GT,TDS> & tr,
|
||||
bool in_3D_export_surface_only = true)
|
||||
{
|
||||
typedef Triangulation<GT,TDS> Tr;
|
||||
typedef typename Tr::Vertex_const_handle Vertex_handle;
|
||||
|
|
@ -162,21 +163,53 @@ export_triangulation_to_off(std::ostream & os,
|
|||
}
|
||||
else if (tr.maximal_dimension() == 3)
|
||||
{
|
||||
// Parse boundary facets
|
||||
for (Full_cell_iterator fch = tr.full_cells_begin() ;
|
||||
fch != tr.full_cells_end() ; ++fch)
|
||||
if (in_3D_export_surface_only)
|
||||
{
|
||||
if (tr.is_infinite(fch))
|
||||
// Parse boundary facets
|
||||
for (Full_cell_iterator fch = tr.full_cells_begin() ;
|
||||
fch != tr.full_cells_end() ; ++fch)
|
||||
{
|
||||
output << "3 ";
|
||||
for (Full_cell_vertex_iterator vit = fch->vertices_begin() ;
|
||||
vit != fch->vertices_end() ; ++vit, ++i)
|
||||
if (tr.is_infinite(fch))
|
||||
{
|
||||
if (!tr.is_infinite(*vit))
|
||||
output << index_of_vertex[*vit] << " ";
|
||||
output << "3 ";
|
||||
for (Full_cell_vertex_iterator vit = fch->vertices_begin() ;
|
||||
vit != fch->vertices_end() ; ++vit)
|
||||
{
|
||||
if (!tr.is_infinite(*vit))
|
||||
output << index_of_vertex[*vit] << " ";
|
||||
}
|
||||
output << std::endl;
|
||||
++number_of_triangles;
|
||||
}
|
||||
output << std::endl;
|
||||
++number_of_triangles;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parse boundary facets
|
||||
for (Finite_full_cell_iterator fch = tr.finite_full_cells_begin() ;
|
||||
fch != tr.finite_full_cells_end() ; ++fch)
|
||||
{
|
||||
output << "3 "
|
||||
<< index_of_vertex[fch->vertex(0)] << " "
|
||||
<< index_of_vertex[fch->vertex(1)] << " "
|
||||
<< index_of_vertex[fch->vertex(2)]
|
||||
<< std::endl;
|
||||
output << "3 "
|
||||
<< index_of_vertex[fch->vertex(0)] << " "
|
||||
<< index_of_vertex[fch->vertex(2)] << " "
|
||||
<< index_of_vertex[fch->vertex(3)]
|
||||
<< std::endl;
|
||||
output << "3 "
|
||||
<< index_of_vertex[fch->vertex(1)] << " "
|
||||
<< index_of_vertex[fch->vertex(2)] << " "
|
||||
<< index_of_vertex[fch->vertex(3)]
|
||||
<< std::endl;
|
||||
output << "3 "
|
||||
<< index_of_vertex[fch->vertex(0)] << " "
|
||||
<< index_of_vertex[fch->vertex(1)] << " "
|
||||
<< index_of_vertex[fch->vertex(3)]
|
||||
<< std::endl;
|
||||
number_of_triangles += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue