mirror of https://github.com/CGAL/cgal
Changing the testsuite to the new interface
TODO: Union of balls example
This commit is contained in:
parent
5c457fa2f3
commit
abd4797802
|
|
@ -1,6 +1,6 @@
|
|||
// examples/Skin_surface_3/union_of_balls_simple.C
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Union_of_balls_3.h>
|
||||
#include <CGAL/union_of_balls_3.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
// #include <CGAL/mesh_union_of_balls_3.h>
|
||||
#include <list>
|
||||
|
|
|
|||
|
|
@ -32,63 +32,92 @@ bool test(char * filename, double shrink) {
|
|||
|
||||
int main(int argc, char *argv[]) {
|
||||
bool result;
|
||||
char *filename;
|
||||
|
||||
result = test("data/caffeine.cin", .5);
|
||||
filename = "data/caffeine.cin";
|
||||
result = test(filename, .5);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/ball.cin", .5);
|
||||
filename = "data/ball.cin";
|
||||
result = test(filename, .5);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/degenerate.cin", .5);
|
||||
filename = "data/degenerate.cin";
|
||||
result = test(filename, .5);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test1.cin", .5);
|
||||
filename = "data/test1.cin";
|
||||
result = test(filename, .5);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test2.cin", .5);
|
||||
filename = "data/test2.cin";
|
||||
result = test(filename, .5);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test3.cin", .5);
|
||||
filename = "data/test3.cin";
|
||||
result = test(filename, .5);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test4.cin", .5);
|
||||
filename = "data/test4.cin";
|
||||
result = test(filename, .5);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test5.cin", .5);
|
||||
filename = "data/test5.cin";
|
||||
result = test(filename, .5);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test6.cin", .5);
|
||||
filename = "data/test6.cin";
|
||||
result = test(filename, .5);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test7.cin", .5);
|
||||
filename = "data/test7.cin";
|
||||
result = test(filename, .5);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test8.cin", .5);
|
||||
filename = "data/test8.cin";
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test9.cin", .5);
|
||||
result = test(filename, .5);
|
||||
filename = "data/test9.cin";
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test10.cin", .5);
|
||||
result = test(filename, .5);
|
||||
filename = "data/test10.cin";
|
||||
result = test(filename, .5);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test11.cin", .5);
|
||||
filename = "data/test11.cin";
|
||||
result = test(filename, .5);
|
||||
CGAL_assertion(result);
|
||||
|
||||
result = test("data/caffeine.cin", .85);
|
||||
filename = "data/caffeine.cin";
|
||||
result = test(filename, .85);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/ball.cin", .85);
|
||||
filename = "data/ball.cin";
|
||||
result = test(filename, .85);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/degenerate.cin", .85);
|
||||
filename = "data/degenerate.cin";
|
||||
result = test(filename, .85);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test1.cin", .85);
|
||||
filename = "data/test1.cin";
|
||||
result = test(filename, .85);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test2.cin", .85);
|
||||
filename = "data/test2.cin";
|
||||
result = test(filename, .85);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test3.cin", .85);
|
||||
filename = "data/test3.cin";
|
||||
result = test(filename, .85);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test4.cin", .85);
|
||||
filename = "data/test4.cin";
|
||||
result = test(filename, .85);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test5.cin", .85);
|
||||
filename = "data/test5.cin";
|
||||
result = test(filename, .85);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test6.cin", .85);
|
||||
filename = "data/test6.cin";
|
||||
result = test(filename, .85);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test7.cin", .85);
|
||||
filename = "data/test7.cin";
|
||||
result = test(filename, .85);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test8.cin", .85);
|
||||
filename = "data/test8.cin";
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test9.cin", .85);
|
||||
result = test(filename, .85);
|
||||
filename = "data/test9.cin";
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test10.cin", .85);
|
||||
result = test(filename, .85);
|
||||
filename = "data/test10.cin";
|
||||
result = test(filename, .85);
|
||||
CGAL_assertion(result);
|
||||
result = test("data/test11.cin", .85);
|
||||
filename = "data/test11.cin";
|
||||
result = test(filename, .85);
|
||||
CGAL_assertion(result);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,128 +1,79 @@
|
|||
// test/Skin_surface_3/subdivision_test.C
|
||||
#include <CGAL/skin_surface_3.h>
|
||||
#include <CGAL/Skin_surface_traits_3.h>
|
||||
#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
|
||||
#include <CGAL/Regular_triangulation_3.h>
|
||||
#include <CGAL/Triangulated_mixed_complex_3.h>
|
||||
#include <CGAL/triangulate_mixed_complex_3.h>
|
||||
#include <CGAL/Marching_tetrahedra_traits_skin_surface_3.h>
|
||||
#include <CGAL/Marching_tetrahedra_observer_default_3.h>
|
||||
#include <CGAL/Marching_tetrahedra_observer_skin_surface_3.h>
|
||||
#include <CGAL/marching_tetrahedra_3.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Skin_surface_3.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
|
||||
#include <CGAL/Skin_surface_refinement_traits_3.h>
|
||||
#include <CGAL/Skin_surface_refinement_traits_with_face_info_3.h>
|
||||
|
||||
#include <CGAL/Skin_surface_polyhedral_items_3.h>
|
||||
|
||||
#include <CGAL/skin_surface_sqrt3_3.h>
|
||||
|
||||
typedef CGAL::Skin_surface_traits_3<> Skin_traits;
|
||||
typedef Skin_traits::Regular_traits Regular_traits;
|
||||
|
||||
typedef CGAL::Regular_triangulation_3<Regular_traits> Regular;
|
||||
typedef Regular_traits::Weighted_point Reg_weighted_point;
|
||||
typedef Regular_traits::Bare_point Reg_point;
|
||||
|
||||
typedef CGAL::Triangulated_mixed_complex_3<Skin_traits> Tr2;
|
||||
typedef Tr2::Cell_handle Tr2_cell_handle;
|
||||
typedef Tr2::Finite_cells_iterator Tr2_Fin_cells_it;
|
||||
typedef Tr2::Finite_vertices_iterator Tr2_Fin_vertices_it;
|
||||
|
||||
typedef Skin_traits::Polyhedron_traits Polyhedron_kernel;
|
||||
typedef CGAL::Polyhedron_3<Polyhedron_kernel> Polyhedron;
|
||||
|
||||
typedef CGAL::Skin_surface_polyhedral_items_3<Tr2> Polyhedral_items;
|
||||
typedef CGAL::Polyhedron_3<Polyhedron_kernel, Polyhedral_items>
|
||||
Polyhedron_plus;
|
||||
|
||||
typedef Polyhedron_kernel::RT Polyhedron_rt;
|
||||
|
||||
typedef CGAL::Marching_tetrahedra_traits_skin_surface_3<
|
||||
Tr2, Polyhedron, Skin_traits::T2P_converter> Marching_tetrahedra_traits;
|
||||
|
||||
typedef CGAL::Marching_tetrahedra_observer_default_3<
|
||||
Tr2, Polyhedron> Marching_observer_default;
|
||||
typedef CGAL::Marching_tetrahedra_observer_skin_surface_3<
|
||||
Tr2, Polyhedron_plus> Marching_observer_skin_surface;
|
||||
|
||||
typedef CGAL::Skin_surface_refinement_traits_3<
|
||||
Tr2,
|
||||
Polyhedron,
|
||||
Skin_traits::T2P_converter,
|
||||
Skin_traits::P2T_converter> Skin_refinement_traits;
|
||||
|
||||
typedef CGAL::Skin_surface_refinement_traits_with_face_info_3<
|
||||
Tr2,
|
||||
Polyhedron_plus,
|
||||
Skin_traits::T2P_converter,
|
||||
Skin_traits::P2T_converter> Skin_refinement_traits_plus;
|
||||
|
||||
#include <CGAL/mesh_skin_surface_3.h>
|
||||
#include <CGAL/subdivide_skin_surface_mesh_3.h>
|
||||
#include <list>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef CGAL::Regular_triangulation_euclidean_traits_3<K> Traits;
|
||||
typedef CGAL::Skin_surface_3<Traits> Skin_surface_3;
|
||||
typedef Skin_surface_3::FT FT;
|
||||
typedef Skin_surface_3::Weighted_point Weighted_point;
|
||||
typedef Skin_surface_3::Bare_point Bare_point;
|
||||
typedef CGAL::Polyhedron_3<K> Polyhedron;
|
||||
|
||||
template < class Triangulated_mixed_complex,
|
||||
class Polyhedron,
|
||||
class Marching_traits,
|
||||
class Marching_observer,
|
||||
class Skin_surface_refinement_traits>
|
||||
void construct_and_subdivide_mesh(
|
||||
Triangulated_mixed_complex &triangulated_mixed_complex,
|
||||
Polyhedron &polyhedron,
|
||||
Marching_traits &marching_traits,
|
||||
Marching_observer &marching_observer,
|
||||
Skin_surface_refinement_traits &refinement_traits) {
|
||||
typedef CGAL::Skin_surface_polyhedral_items_3<Skin_surface_3> Poly_items_skin;
|
||||
typedef CGAL::Polyhedron_3<K,Poly_items_skin> Polyhedron_skin;
|
||||
|
||||
CGAL::marching_tetrahedra_3(
|
||||
triangulated_mixed_complex, polyhedron, marching_traits, marching_observer);
|
||||
|
||||
CGAL::skin_surface_sqrt3(polyhedron, refinement_traits, 4);
|
||||
#include <fstream>
|
||||
|
||||
Skin_surface_3 create_skin_surface(char * filename, double shrink) {
|
||||
std::list<Weighted_point> l;
|
||||
std::ifstream in(filename);
|
||||
CGAL_assertion(in.is_open());
|
||||
Weighted_point wp;
|
||||
while (in >> wp) l.push_front(wp);
|
||||
|
||||
return Skin_surface_3(l.begin(), l.end(), shrink);
|
||||
}
|
||||
|
||||
template < class Skin_surface_3, class Polyhedron>
|
||||
bool construct_and_subdivide_mesh(Skin_surface_3 &skin_surface,
|
||||
Polyhedron &polyhedron)
|
||||
{
|
||||
CGAL::mesh_skin_surface_3(skin_surface, polyhedron);
|
||||
CGAL_assertion(polyhedron.is_valid() && polyhedron.is_closed());
|
||||
|
||||
CGAL::subdivide_skin_surface_mesh_3(polyhedron, skin_surface);
|
||||
return (polyhedron.is_valid() && polyhedron.is_closed());
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
double shrink = .85;
|
||||
Skin_traits skin_traits(shrink);
|
||||
Marching_tetrahedra_traits marching_traits;
|
||||
while (argc>1) {
|
||||
argc--; argv++;
|
||||
std::ifstream is(argv[0]);
|
||||
|
||||
Regular regular;
|
||||
Reg_weighted_point wp;
|
||||
bool result;
|
||||
|
||||
while (is >> wp) regular.insert(wp);
|
||||
CGAL::skin_surface_construct_bounding_box_3(regular, skin_traits);
|
||||
std::vector<char *> filenames;
|
||||
filenames.push_back("data/caffeine.cin");
|
||||
filenames.push_back("data/ball.cin");
|
||||
filenames.push_back("data/degenerate.cin");
|
||||
filenames.push_back("data/test1.cin");
|
||||
filenames.push_back("data/test2.cin");
|
||||
filenames.push_back("data/test3.cin");
|
||||
filenames.push_back("data/test4.cin");
|
||||
filenames.push_back("data/test5.cin");
|
||||
filenames.push_back("data/test6.cin");
|
||||
filenames.push_back("data/test7.cin");
|
||||
filenames.push_back("data/test8.cin");
|
||||
filenames.push_back("data/test9.cin");
|
||||
filenames.push_back("data/test10.cin");
|
||||
filenames.push_back("data/test11.cin");
|
||||
|
||||
// Triangulate mixed complex:
|
||||
Tr2 triangulated_mixed_complex;
|
||||
CGAL::triangulate_mixed_complex_3(
|
||||
regular, triangulated_mixed_complex, skin_traits);
|
||||
Polyhedron p;
|
||||
Polyhedron_skin p_skin;
|
||||
for (std::vector<char *>::size_type i=0; i<filenames.size(); i++) {
|
||||
Skin_surface_3 skin_surface = create_skin_surface(filenames[i], .5);
|
||||
Polyhedron p;
|
||||
|
||||
|
||||
Polyhedron polyhedron;
|
||||
Marching_tetrahedra_traits marching_traits;
|
||||
Marching_observer_default marching_observer;
|
||||
Skin_refinement_traits refinement_traits(triangulated_mixed_complex);
|
||||
result = construct_and_subdivide_mesh(skin_surface, p);
|
||||
CGAL_assertion(result);
|
||||
p.clear();
|
||||
|
||||
// Without additional face information in the polyhedron
|
||||
construct_and_subdivide_mesh(
|
||||
triangulated_mixed_complex, polyhedron,
|
||||
marching_traits, marching_observer,
|
||||
refinement_traits);
|
||||
|
||||
Polyhedron_plus polyhedron_plus;
|
||||
Marching_observer_skin_surface marching_observer_plus;
|
||||
Skin_refinement_traits_plus
|
||||
refinement_traits_plus(triangulated_mixed_complex);
|
||||
|
||||
// With additional face information in the polyhedron
|
||||
construct_and_subdivide_mesh(
|
||||
triangulated_mixed_complex, polyhedron_plus,
|
||||
marching_traits, marching_observer_plus,
|
||||
refinement_traits_plus);
|
||||
|
||||
result = construct_and_subdivide_mesh(skin_surface, p_skin);
|
||||
CGAL_assertion(result);
|
||||
p_skin.clear();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue