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
|
2
|
||||||
0.0071 1.6899 1.2 0
|
0.0071 1.6899 0
|
||||||
0.3272 1.3694 0.05
|
0.3272 1.3694 0.05
|
||||||
1.3697 1.8296 0.1
|
1.3697 1.8296 0.1
|
||||||
0.6722 0.3012 0.15
|
0.6722 0.3012 0.15
|
||||||
1.1726 0.1899 0.2
|
1.1726 0.1899 0.2
|
||||||
0.4374 2.8541 0.25
|
0.4374 2.8541 100.25
|
||||||
2.5923 0.1904 0.3
|
2.5923 0.1904 0.3
|
||||||
1.3083 2.5462 0.35
|
1.3083 2.5462 200.35
|
||||||
1.4981 1.3929 0.4
|
1.4981 1.3929 0.4
|
||||||
2.1304 2.055 0.45
|
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_euclidean_traits<K> Traits;
|
||||||
typedef CGAL::Regular_triangulation<Traits> RT;
|
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;
|
RT::Weighted_point wp;
|
||||||
std::vector<RT::Weighted_point> wpoints;
|
std::vector<RT::Weighted_point> wpoints;
|
||||||
|
|
||||||
int dim;
|
int dim_from_file;
|
||||||
in >> dim;
|
in >> dim_from_file;
|
||||||
while(in >> wp)
|
while(in >> wp)
|
||||||
wpoints.push_back(wp);
|
wpoints.push_back(wp);
|
||||||
|
|
||||||
// Build the Regular Triangulation
|
// Build the Regular Triangulation
|
||||||
RT rt(dim);
|
RT rt(dim_from_file);
|
||||||
rt.insert(wpoints.begin(), wpoints.end());
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,8 @@ operator>>(std::istream &is, typename Wrap::Weighted_point_d<K> & wp)
|
||||||
template < class GT, class TDS >
|
template < class GT, class TDS >
|
||||||
std::ostream &
|
std::ostream &
|
||||||
export_triangulation_to_off(std::ostream & os,
|
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 Triangulation<GT,TDS> Tr;
|
||||||
typedef typename Tr::Vertex_const_handle Vertex_handle;
|
typedef typename Tr::Vertex_const_handle Vertex_handle;
|
||||||
|
|
@ -161,6 +162,8 @@ export_triangulation_to_off(std::ostream & os,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tr.maximal_dimension() == 3)
|
else if (tr.maximal_dimension() == 3)
|
||||||
|
{
|
||||||
|
if (in_3D_export_surface_only)
|
||||||
{
|
{
|
||||||
// Parse boundary facets
|
// Parse boundary facets
|
||||||
for (Full_cell_iterator fch = tr.full_cells_begin() ;
|
for (Full_cell_iterator fch = tr.full_cells_begin() ;
|
||||||
|
|
@ -170,7 +173,7 @@ export_triangulation_to_off(std::ostream & os,
|
||||||
{
|
{
|
||||||
output << "3 ";
|
output << "3 ";
|
||||||
for (Full_cell_vertex_iterator vit = fch->vertices_begin() ;
|
for (Full_cell_vertex_iterator vit = fch->vertices_begin() ;
|
||||||
vit != fch->vertices_end() ; ++vit, ++i)
|
vit != fch->vertices_end() ; ++vit)
|
||||||
{
|
{
|
||||||
if (!tr.is_infinite(*vit))
|
if (!tr.is_infinite(*vit))
|
||||||
output << index_of_vertex[*vit] << " ";
|
output << index_of_vertex[*vit] << " ";
|
||||||
|
|
@ -180,6 +183,36 @@ export_triangulation_to_off(std::ostream & os,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
os << "OFF \n"
|
os << "OFF \n"
|
||||||
<< n << " "
|
<< n << " "
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue