Merging entities that do not have any overlap in CGAL requires creating a new entity that encompasses both of the original entities. This can be done by defining a new bounding box or convex hull that includes both entities.
Here are the general steps to follow:
Here is some C++ code that demonstrates the creation of an encompassing bounding box for two sets of points:
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/convex_hull_2.h>
#include <CGAL/OBB_tree_3.h>
#include <CGAL/point_generators_3.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point_3;
typedef K::Vector_3 Vector_3;
int main()
{
std::vector<Point_3> points1, points2;
// populate points1 and points2 with the sets of points
// compute the extents of each set of points
CGAL::Min_max_diameter_d::Point_with_id<Point_3> min_max1 = CGAL::min_max_diameter(points1.begin(), points1.end());
CGAL::Min_max_diameter_d::Point_with_id<Point_3> min_max2 = CGAL::min_max_diameter(points2.begin(), points2.end());
// compute the union of the two extents to create a new encompassing extent
Point_3 lower_left(std::min(min_max1.first.x(), min_max2.first.x()),
std::min(min_max1.first.y(), min_max2.first.y()),
std::min(min_max1.first.z(), min_max2.first.z()));
Point_3 upper_right(std::max(min_max1.second.x(), min_max2.second.x()),
std::max(min_max1.second.y(), min_max2.second.y()),
std::max(min_max1.second.z(), min_max2.second.z()));
// compute the set of points that lie within the new extent
std::vector<Point_3> all_points;
all_points.reserve(points1.size() + points2.size());
all_points.insert(all_points.end(), points1.begin(), points1.end());
all_points.insert(all_points.end(), points2.begin(), points2.end());
CGAL::OBB_tree_3<K> obb(all_points.begin(), all_points.end());
std::vector<Point_3> new_points;
obb.all_points(new_points);
// Create a new CGAL object that encompasses both original sets of points.
CGAL::convex_hull_3(new_points.begin(), new_points.end(), hull);
}
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-08-24 11:00:00 +0000
Seen: 11 times
Last updated: Sep 13 '22
What does an empty name signify in the inotify_event structure in the C++ language?
What is the method to get a printable output of a C++11 time_point?
What are the differences between TREEFROG, CROW, and the CPPCMS C++ framework?
How can the NTP flag be set for Linux time in C++?
What is the process of redefining a c++ macro with fewer parameters?
What are some other options instead of Scipy to compute CubicSpline?
How can a list be sorted alphabetically within a console application?