Skip to content

Commit

Permalink
WIP: direct minkowski_sum_3/buffer 3D test
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti committed Jul 31, 2024
1 parent e1f9fab commit 2041332
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/unit/SFCGAL/algorithm/MinkowskiSumTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*/
#include <boost/test/unit_test.hpp>

#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/minkowski_sum_3.h>

#include "SFCGAL/GeometryCollection.h"
#include "SFCGAL/Kernel.h"
#include "SFCGAL/LineString.h"
Expand All @@ -36,6 +39,8 @@
#include "SFCGAL/algorithm/minkowskiSum.h"
#include "SFCGAL/detail/generator/hoch.h"
#include "SFCGAL/io/wkt.h"
#include "SFCGAL/PolyhedralSurface.h"
#include "SFCGAL/Sphere.h"

#include "SFCGAL/detail/tools/Registry.h"

Expand Down Expand Up @@ -177,4 +182,51 @@ BOOST_AUTO_TEST_CASE(testMultiPoint)
"MULTIPOLYGON(((0 1,-1 0,0 -1,1 0,0 1)),((5 6,4 5,5 4,6 5,5 6)))");
}

BOOST_AUTO_TEST_CASE(testBuffer3D)
{

Kernel::FT radius{10};
int num_vertical{4};
int num_horizontal{8};

Kernel::Point_3 center(0, 0, 0);
SFCGAL::Sphere sphere(radius, center, num_vertical, num_horizontal);

// Generate and print point cloud
std::vector<SFCGAL::Kernel::Point_3> points = sphere.generatePoints();
std::cout << "Point cloud generated with " << points.size() << " points." << std::endl;

// Generate and print polyhedron
CGAL::Polyhedron_3<SFCGAL::Kernel> polyhedron = sphere.generatePolyhedron();
std::cout << "Polyhedron generated with " << polyhedron.size_of_vertices() << " vertices and "
<< polyhedron.size_of_facets() << " facets." << std::endl;

// Convert Polyhedron to a Nef_polyhedron
CGAL::Nef_polyhedron_3<SFCGAL::Kernel> N0(polyhedron);

// Create a polyline for N1
std::vector<SFCGAL::Kernel::Point_3> polyline_points = {
SFCGAL::Kernel::Point_3(-100, 0, 0),
SFCGAL::Kernel::Point_3(40, -70, 0),
SFCGAL::Kernel::Point_3(40, 50, 40),
SFCGAL::Kernel::Point_3(-90, -60, 60),
SFCGAL::Kernel::Point_3(0, 0, -100),
SFCGAL::Kernel::Point_3(30, 0, 150)
};

CGAL::Nef_polyhedron_3<SFCGAL::Kernel> N1(polyline_points.begin(), polyline_points.end(),
CGAL::Nef_polyhedron_3<SFCGAL::Kernel>::Points_tag());

// Perform Minkowski sum
CGAL::Nef_polyhedron_3<SFCGAL::Kernel> result = CGAL::minkowski_sum_3(N0, N1);

std::cout << "Minkowski sum completed." << std::endl;

// Convert result to SFCGAL::PolyhedralSurface and print
SFCGAL::detail::MarkedPolyhedron out;
result.convert_to_polyhedron(out);
SFCGAL::PolyhedralSurface ps{out};
std::cout << ps.asText(1) << std::endl;
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 2041332

Please sign in to comment.