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

Fix dangling reference in Construct_center_3(Circle_3) #8586

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ee451ed
Fix dangling reference in Construct_center_3(Circle_3)
MaelRL Nov 2, 2024
dd2fca2
Actually test the full EPECK family
MaelRL Nov 3, 2024
425fe50
Add missing tests for filtered Cartesian kernels
MaelRL Nov 3, 2024
69c9aba
Remove obsolete debug cout
MaelRL Nov 3, 2024
b32491a
Revert sidechange
MaelRL Nov 3, 2024
181ccd2
More instances of result_type --> dcltype(auto)
MaelRL Nov 6, 2024
b02776b
Remove wrong result_type (WIP: does not compile anymore)
MaelRL Nov 6, 2024
0d452b7
Remove extra parenthesis
MaelRL Nov 12, 2024
dcb38f3
Fix broken doc link
MaelRL Nov 12, 2024
a052572
Remove unused functor
MaelRL Dec 12, 2024
ea9c2a3
Remove unused functors
MaelRL Dec 12, 2024
8524c6a
Remove unused functors
MaelRL Dec 12, 2024
abc4fe6
Remove unused Lazy_rep objects
MaelRL Dec 17, 2024
db1fa6d
Factorize Lazy_construction_object into a single operator()
MaelRL Dec 17, 2024
7f1e16d
Factorize operator()s of Lazy_construction_variant
MaelRL Dec 17, 2024
4783005
Remove unused functor
MaelRL Dec 17, 2024
9188e8a
Fix name: polygonal_envelope > polyhedral_envelope
MaelRL Dec 17, 2024
9d10860
Use a single Lazy_construction class
MaelRL Dec 18, 2024
7b6755f
Remove code that was used to filter between different lazy constructions
MaelRL Dec 18, 2024
778ae1b
Remove unused class
MaelRL Dec 20, 2024
9c9892c
Use variadic functions in Static_filtered_predicate
MaelRL Dec 20, 2024
6b1e666
Remove superfluous code in Lazy_construction
MaelRL Dec 20, 2024
e534750
Fix but don't fix broken Has_static_filters for EPECK
MaelRL Dec 20, 2024
a886420
Misc cleaning
MaelRL Dec 20, 2024
468dde7
Use a clearer name than "Static_filtered_predicate" for EPECK static …
MaelRL Dec 20, 2024
4d4549c
Get rid of result_type in Kernels + fix some bad return types (wip)
MaelRL Dec 20, 2024
9c517a4
Fix bad return types
MaelRL Dec 20, 2024
c22fada
Do not rely on the predicate providing result_type in Filtered_predicate
MaelRL Dec 20, 2024
7b6886e
Misc cleaning
MaelRL Dec 20, 2024
7b160e3
Template the Uncertain enum_cast overload with Uncertain, not base enum
MaelRL Dec 29, 2024
c85b388
Update test for enum_cast<Uncertain>
MaelRL Dec 29, 2024
040f965
Fix include filename
MaelRL Dec 29, 2024
f26f41c
Minor CH3 test improvement
MaelRL Dec 29, 2024
b7de40a
Update enum_cast<Uncertain> calls to new API
MaelRL Jan 8, 2025
b8830ca
Remove superfluous precision
MaelRL Jan 8, 2025
8c95fcc
Update Filtered_predicate_with_state not to rely on a 'result_type' t…
MaelRL Jan 8, 2025
d02e817
Get rid of result types in function objects of Circular_kernel_23
MaelRL Jan 8, 2025
981e68c
Fix using non-existant has_on_2 API
MaelRL Jan 8, 2025
30064c1
Do not return const values
MaelRL Jan 8, 2025
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
2 changes: 1 addition & 1 deletion Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class CircleC3 {
return diametral_sphere();
}

Point_3 center() const
decltype(auto) center() const
{
return diametral_sphere().center();
}
Expand Down
6 changes: 3 additions & 3 deletions Kernel_23/include/CGAL/Circle_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ template <class R_>
return typename R::Construct_sphere_3()(*this);
}

Point_3 center() const
decltype(auto) center() const
{
return typename R::Construct_sphere_3()(*this).center();
return diametral_sphere().center();
}

FT squared_radius() const
MaelRL marked this conversation as resolved.
Show resolved Hide resolved
{
return typename R::Construct_sphere_3()(*this).squared_radius();
return diametral_sphere().squared_radius();
}

decltype(auto)
Expand Down
8 changes: 3 additions & 5 deletions Kernel_23/include/CGAL/Kernel/function_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -2523,9 +2523,8 @@ namespace CommonKernelFunctors {
typedef typename K::Sphere_3 Sphere_3;
typedef typename K::Circle_3 Circle_3;
typedef typename Sphere_3::Rep Rep;
public:
typedef Sphere_3 result_type;

public:
Rep // Sphere_3
operator()(Return_base_tag, const Point_3& center, const FT& squared_radius,
Orientation orientation = COUNTERCLOCKWISE) const
Expand All @@ -2551,7 +2550,7 @@ namespace CommonKernelFunctors {
Orientation orientation = COUNTERCLOCKWISE) const
{ return Rep(center, orientation); }

Rep
decltype(auto)
operator() (Return_base_tag, const Circle_3 & c) const
{ return c.rep().diametral_sphere(); }

Expand Down Expand Up @@ -2580,10 +2579,9 @@ namespace CommonKernelFunctors {
Orientation orientation = COUNTERCLOCKWISE) const
{ return this->operator()(Return_base_tag(), center, orientation); }

Sphere_3
decltype(auto)
operator() (const Circle_3 & c) const
{ return this->operator()(Return_base_tag(), c); }

};

template <typename K>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,76 @@
#endif
#include <CGAL/use.h>

int main(){
#include "CGAL/_test_cls_kernel.h"
#define TEST_FILENAME "Test-Cartesian-IO.out"
#include "CGAL/_test_io.h"
#include "CGAL/_test_2.h"
#include "CGAL/_test_3.h"

typedef CGAL::Exact_predicates_exact_constructions_kernel EPEK;
CGAL_USE_TYPE(EPEK);
#include "CGAL/_test_new_2.h"
#include "CGAL/_test_new_3.h"

#include "CGAL/_test_fct_points_implicit_sphere.h"
#include "CGAL/_test_orientation_and_bounded_side.h"
#include "CGAL/_test_fct_constructions_2.h"
#include "CGAL/_test_fct_constructions_3.h"
#include "CGAL/_test_fct_point_3.h"
#include "CGAL/_test_fct_coplanar_3.h"
#include "CGAL/_test_cls_iso_cuboid_3.h"
#include "CGAL/_test_angle.h"
#include "CGAL/_test_cls_circle_3.h"

#include "CGAL/_test_mf_plane_3_to_2d.h"

template <typename K>
void test()
{
CGAL_USE_TYPE(K);

std::cout << "Testing nested types with:" << typeid(K).name() << std::endl;
_test_kernel( K() );

std::cout << "Testing IO with:" << typeid(K).name() << std::endl;
_test_io( K() );

std::cout << "Testing 2d with:" << typeid(K).name() << std::endl;
_test_2( K() );

std::cout << "Testing 3d with:" << typeid(K).name() << std::endl;
_test_3( K() );
_test_cls_circle_3( K() );

std::cout << "Testing new 2d with:" << typeid(K).name() << std::endl;
test_new_2( K() );
_test_cls_new_2( K() );

std::cout << "Testing new 3d with:" << typeid(K).name() << std::endl;
test_new_3( K() );

std::cout << "Testing new parts with:" << typeid(K).name() << std::endl;
_test_orientation_and_bounded_side( K() );
_test_fct_points_implicit_sphere( K() );
_test_fct_constructions_2( K() );
_test_fct_constructions_3( K() );
_test_fct_point_3( K() );
_test_fct_coplanar_3( K() );
_test_cls_iso_cuboid_3( K() );
_test_angle( K() );

std::cout << "Testing 3d-2d with:" << typeid(K).name() << std::endl;
_test_mf_plane_3_to_2d( K() );

std::cout << "All tests done" << std::endl;
}

int main()
{
test<CGAL::Exact_predicates_exact_constructions_kernel>();

#if defined(CGAL_USE_CORE) || defined(CGAL_USE_LEDA)
typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EPEKS;
typedef CGAL::Exact_predicates_exact_constructions_kernel_with_kth_root EPEKK;
typedef CGAL::Exact_predicates_exact_constructions_kernel_with_root_of EPEKR;
CGAL_USE_TYPE(EPEKS);
CGAL_USE_TYPE(EPEKK);
CGAL_USE_TYPE(EPEKR);
test<CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt>();
test<CGAL::Exact_predicates_exact_constructions_kernel_with_kth_root>();
test<CGAL::Exact_predicates_exact_constructions_kernel_with_root_of>();
#endif

return 0;
Expand Down
18 changes: 16 additions & 2 deletions Kernel_23/test/Kernel_23/Filtered_cartesian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "CGAL/_test_fct_coplanar_3.h"
#include "CGAL/_test_cls_iso_cuboid_3.h"
#include "CGAL/_test_angle.h"
#include "CGAL/_test_cls_circle_3.h"

#include "CGAL/_test_mf_plane_3_to_2d.h"

Expand All @@ -59,6 +60,9 @@ main()
typedef CGAL::Cartesian<double> Clsdb;
typedef CGAL::Filtered_kernel<Clsdb> Clsd;

std::cout << "Testing IO with F_k<Cartesian<double>>:" << std::endl;
_test_io( Clsd() );

// typedef CGAL::Cartesian<CGAL::Quotient<Precise_integer> > Clsb;
// typedef CGAL::Cartesian<CGAL::Quotient<CGAL::MP_Float> > Clsb;
// typedef CGAL::Filtered_kernel<Clsb> Cls;
Expand All @@ -69,20 +73,22 @@ main()
// "Testing with Filtered_kernel<Cartesian<Quotient<MP_Float>>>:"
"Testing with Exact_predicates_exact_constructions_kernel:"
<< std::endl;
std::cout << "Testing IO with F_k<Cartesian<double>>:" << std::endl;
_test_io( Clsd() );


std::cout << "Testing with Epeck:\n";
test<Cls>();

std::cout << "Testing with Double_precision_epick:\n";
test<CGAL::Double_precision_epick>();

# if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable: 4244)
# endif

std::cout << "Testing with Simple_precision_epick:\n";
test<CGAL::Single_precision_epick>();

# if defined(BOOST_MSVC)
# pragma warning(pop)
# endif
Expand All @@ -92,21 +98,27 @@ main()

template <typename Cls>
void test() {
std::cout << "Testing IO :" << std::endl;
_test_io( Cls() );

std::cout << "Testing 2d :";
std::cout << std::endl;
_test_2( Cls() );

std::cout << "Testing 3d :";
std::cout << std::endl;
_test_3( Cls() );
_test_cls_circle_3( Cls() );

std::cout << "Testing new 2d :";
std::cout << std::endl;
test_new_2( Cls() );
_test_cls_new_2( Cls() );

std::cout << "Testing new 3d :";
std::cout << std::endl;
test_new_3( Cls() );
_test_cls_circle_3( Cls() );

std::cout << "Testing new parts :";
std::cout << std::endl;
Expand All @@ -122,4 +134,6 @@ void test() {
std::cout << "Testing 3d-2d :";
std::cout << std::endl;
_test_mf_plane_3_to_2d( Cls() );

std::cout << "Done Testing " << typeid(Cls).name() << std::endl;
}
1 change: 1 addition & 0 deletions Kernel_23/test/Kernel_23/include/CGAL/_approx_equal.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef CGAL_TESTSUITE_APPROX_EQUAL_H
#define CGAL_TESTSUITE_APPROX_EQUAL_H

#include <boost/math/special_functions/next.hpp>

namespace CGAL {
Expand Down
83 changes: 52 additions & 31 deletions Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
#ifndef CGAL__TEST_CLS_CIRCLE_3_H
#define CGAL__TEST_CLS_CIRCLE_3_H

#include "_approx_equal.h"

#include <CGAL/Bbox_2.h>
#include <CGAL/Random.h>

#include <cassert>

// Some predicates and constructions tests related to the class Circle_3 are done here
Expand All @@ -33,9 +36,11 @@ void _test_bounding_box_construct(const K &k)
typedef typename K::Plane_3 Plane_3;
typedef typename K::Sphere_3 Sphere_3;
typedef typename K::Circle_3 Circle_3;
typedef typename K::Construct_bbox_3 Construct_bbox_3;
typedef typename K::Construct_circle_3 Construct_circle_3;
typedef CGAL::Bbox_3 Bbox_3;

Construct_bbox_3 bbox = k.construct_bbox_3_object();
Construct_circle_3 theConstruct_circle_3 = k.construct_circle_3_object();

std::cout << "Testing the bbox of Circle_3..." << std::endl;
Expand All @@ -44,7 +49,7 @@ void _test_bounding_box_construct(const K &k)
Circle_3 c;

c = theConstruct_circle_3(Point_3(0,0,0), 1, Plane_3(1, 0, 0, 0));
b = c.bbox();
b = bbox(c);
assert(b.xmin() <= 0.001);
assert(b.xmax() >= -0.001);
assert(b.ymin() <= -0.999);
Expand All @@ -53,7 +58,7 @@ void _test_bounding_box_construct(const K &k)
assert(b.zmax() >= 0.999);

c = theConstruct_circle_3(Sphere_3(Point_3(0,0,0), 1), Plane_3(1, 0, 0, -FT(1)/FT(2)));
b = c.bbox();
b = bbox(c);
assert(b.xmin() <= 0.501);
assert(b.xmax() >= 0.499);
assert(b.ymin() <= (-std::sqrt(0.5)+0.001));
Expand All @@ -72,10 +77,14 @@ void _test_circle_construct(const K &k) {
typedef typename K::Sphere_3 Sphere_3;
typedef typename K::Equal_3 Equal_3;
typedef typename K::Construct_circle_3 Construct_circle_3;
typedef typename K::Construct_center_3 Construct_center_3;
typedef typename K::Compute_squared_distance_3 Compute_squared_distance_3;

const bool nonexact = std::is_floating_point<FT>::value;

Equal_3 theEqual_3 = k.equal_3_object();
Construct_circle_3 theConstruct_circle_3 = k.construct_circle_3_object();
Construct_center_3 center = k.construct_center_3_object();
Compute_squared_distance_3 squared_distance = k.compute_squared_distance_3_object();

CGAL::Random generatorOfgenerator;
Expand Down Expand Up @@ -117,48 +126,53 @@ void _test_circle_construct(const K &k) {
const FT sqr = FT(r);
const Point_3 p = Point_3(x,y,z);
Circle_3 circle = theConstruct_circle_3(p,sqr,plane);

assert(circle.supporting_plane().a() == a);
assert(circle.supporting_plane().b() == b);
assert(circle.supporting_plane().c() == c);
assert(circle.supporting_plane().d() == d);
assert(circle.center().x() == x);
assert(circle.center().y() == y);
assert(circle.center().z() == z);
const Point_3 ctr = center(circle);
assert(ctr.x() == x);
assert(ctr.y() == y);
assert(ctr.z() == z);
assert(circle.squared_radius() == sqr);
Circle_3 circle2 = theConstruct_circle_3(p,sqr,plane2);
Circle_3 circle3 = theConstruct_circle_3(p,sqr,Vector_3(a,b,c));
assert(theEqual_3(circle,circle2));
assert(theEqual_3(circle,circle3));

Plane_3 pus(circle2);
Sphere_3 sus(circle3);
assert(pus == circle2.supporting_plane());
assert(sus == circle3.diametral_sphere());
if(CGAL::is_zero(a*x+b*y*c*z+d)) { // for EPICK
assert(theEqual_3(circle,circle3));
}

Plane_3 pus(circle2);
Sphere_3 sus(circle3);
assert(pus == circle2.supporting_plane());
assert(sus == circle3.diametral_sphere());
}

Point_3 p1, p2, p3;
p1 = Point_3(1,0,0);
p2 = Point_3(0,1,0);
p3 = Point_3(0,0,1);
Circle_3 c = theConstruct_circle_3(p1, p2, p3);
FT r1 = squared_distance(c.center(), p1);
FT r2 = squared_distance(c.center(), p2);
FT r3 = squared_distance(c.center(), p3);
assert(r1 == r2);
assert(r2 == r3);
assert(r3 == c.squared_radius());

p1 = Point_3(1.3,0.2,0.1);
p2 = Point_3(0.57,1.23,3.0);
p3 = Point_3(9,1.2,1.3);
c = theConstruct_circle_3(p1, p2, p3);
r1 = squared_distance(c.center(), p1);
r2 = squared_distance(c.center(), p2);
r3 = squared_distance(c.center(), p3);
assert(r1 == r2);
assert(r2 == r3);
assert(r3 == c.squared_radius());
Circle_3 c = theConstruct_circle_3(p1, p2, p3);
FT r1 = squared_distance(center(c), p1);
FT r2 = squared_distance(center(c), p2);
FT r3 = squared_distance(center(c), p3);
assert(r1 == r2);
assert(r2 == r3);
assert(r3 == c.squared_radius());

if (!nonexact) {
p1 = Point_3(1.3,0.2,0.1);
p2 = Point_3(0.57,1.23,3.0);
p3 = Point_3(9,1.2,1.3);
c = theConstruct_circle_3(p1, p2, p3);
r1 = squared_distance(center(c), p1);
r2 = squared_distance(center(c), p2);
r3 = squared_distance(center(c), p3);
assert(CGAL::testsuite::approx_equal<FT>(r1,r2));
assert(CGAL::testsuite::approx_equal<FT>(r2,r3));
assert(CGAL::testsuite::approx_equal<FT>(r3,c.squared_radius()));
}

// No need to test the constructors based on intersection
// _test_intersect_construct will test it
Expand All @@ -176,6 +190,8 @@ void _test_construct_radical_plane(const K &k) {
typedef typename K::Construct_sphere_3 Construct_sphere_3;
typedef typename K::Construct_radical_plane_3 Construct_radical_plane_3;

const bool nonexact = std::is_floating_point<FT>::value;

Intersect_3 theIntersect_3 = k.intersect_3_object();
Construct_sphere_3 theConstruct_sphere_3 = k.construct_sphere_3_object();
Construct_radical_plane_3 theConstruct_radical_plane_3 = k.construct_radical_plane_3_object();
Expand Down Expand Up @@ -212,13 +228,18 @@ void _test_construct_radical_plane(const K &k) {
else if((d2 == (r+1)*(r+1)) || (d2 == (r-1)*(r-1))) {
Point_3 interp;
assert(assign(interp, intersection_1));
assert(theHas_on_3(p, interp));

if(!nonexact) {
assert(theHas_on_3(p, interp));
}
}
// 1 Intersection Circle
else {
Circle_3 circle1;
assert(assign(circle1, intersection_1));
assert(theHas_on_3(p, circle1));
if(!nonexact) {
assert(theHas_on_3(p, circle1));
}
}
}
}
Expand Down
Loading
Loading