Test fir Surface_mesh AND Polyhedron

This commit is contained in:
Maxime Gimeno 2018-05-23 10:01:56 +02:00
parent a80100ba41
commit c8bb45fb7e
1 changed files with 14 additions and 6 deletions

View File

@ -1,4 +1,5 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/extrude.h>
#include <iostream>
@ -6,6 +7,7 @@
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Surface_mesh<Kernel::Point_3> SMesh;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
template<typename MAP>
struct Bot
@ -34,10 +36,10 @@ struct Top
MAP map;
};
int main(int argc, char* argv[])
template <class Mesh>
void test_mesh(const char* filename)
{
const char* filename = (argc > 1) ? argv[1] : "data/quad.off";
SMesh in, out;
Mesh in, out;
std::ifstream input(filename);
if (!input || !(input >> in))
@ -45,7 +47,7 @@ int main(int argc, char* argv[])
std::cerr << "Error: cannot read Surface Mesh : " << filename << "\n";
assert(!CGAL::is_empty(in));
assert(false);
return 1;
return ;
}
CGAL::Polygon_mesh_processing::extrude_mesh(in, out, Kernel::Vector_3(0.0, 0.0, -1.0), 1.0);
std::ofstream extruded_off("extruded.off");
@ -53,7 +55,7 @@ int main(int argc, char* argv[])
extruded_off.close();
out.clear();
typedef boost::property_map<SMesh, CGAL::vertex_point_t>::type VPMap;
typedef typename boost::property_map<Mesh, CGAL::vertex_point_t>::type VPMap;
Bot<VPMap> bot(get(CGAL::vertex_point, out));
Top<VPMap> top(get(CGAL::vertex_point, out));
CGAL::Polygon_mesh_processing::generic_extrude_mesh(in, out, bot, top);
@ -61,6 +63,12 @@ int main(int argc, char* argv[])
gen_extruded_off << out;
gen_extruded_off.close();
std::cerr << "All done." << std::endl;
}
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/quad.off";
test_mesh<SMesh>(filename);
test_mesh<Polyhedron>(filename);
return 0;
}