Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORE: Accelerate writing to a stream if precision <= 17 #8179

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CGAL_Core/include/CGAL/CORE/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,11 @@ class Expr : public RCExpr {

/// I/O Stream operator<<
inline std::ostream& operator<<(std::ostream& o, const Expr& e) {
o << *(const_cast<ExprRep*>(&e.getRep()));
if (o.precision() > 17) {
o << *(const_cast<ExprRep*>(&e.getRep()));
} else {
o << e.doubleValue();
}
return o;
}
/// I/O Stream operator>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <CGAL/Straight_skeleton_builder_2.h>
#include <CGAL/Polygon_offset_builder_2.h>
#include <CGAL/Straight_skeleton_2/IO/print.h>
#include <CGAL/Timer.h>

#include <memory>

Expand All @@ -32,6 +33,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel EPICK;
typedef CGAL::Exact_predicates_exact_constructions_kernel EPECK;
typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EPECK_w_sqrt;

typedef CGAL::Timer Timer;
template <typename K>
void test_API()
{
Expand Down Expand Up @@ -936,9 +938,12 @@ void test_offset(const char* filename,
int i = 0;
for(const FT& ot : offset_times)
{
Timer t;
t.start();
std::cout << "Offset #" << i++ << " = " << ot << std::endl;
Polygon_with_holes_2_ptr_container offset_poly_with_holes =
CGAL::create_interior_skeleton_and_offset_polygons_with_holes_2(ot, p, K());
std::cout << t.time() << " sec." << std::endl;

std::cout << offset_poly_with_holes.size() << " polygons with holes" << std::endl;
for(const auto& offp : offset_poly_with_holes)
Expand Down Expand Up @@ -1163,6 +1168,10 @@ int main(int, char**)
test_kernel<EPECK>();
test_kernel<EPECK_w_sqrt>();

// those two are really slow
// test_offset<EPECK_w_sqrt>("data/near_degenerate_0.poly");
// test_offset<EPECK_w_sqrt>("data/degenerate20.poly");

std::cout << "Done!" << std::endl;

return EXIT_SUCCESS;
Expand Down