Assertion violation. Arr_segment_traits_2.h Line: 730
Closed this issue · 5 comments
Issue Details
Assertion in library. Program output:
GMP version: 6.2.1
terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
Expr: cv2.is_vertical() ? m_traits.is_in_y_range_2_object()(cv2, *ip) : m_traits.is_in_x_range_2_object()(cv2, *ip)
File: /usr/include/CGAL/Arr_segment_traits_2.h
Line: 730
aborted
As workaround I changed library header, where it calculates intersection point, to use common endpoint if there is one.
Source Code
#include <vector>
#include <gmp.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_sweep_2_algorithms.h>
int main() {
std::cout << "GMP version: " << gmp_version << std::endl;
typedef CGAL::Exact_predicates_inexact_constructions_kernel::Point_2 P;
typedef CGAL::Exact_predicates_inexact_constructions_kernel::Segment_2 S;
std::vector<S> seg = {
S(P(-9.0940291, -20.8188387), P(-10, -19.8005205)),
S(P(-10, -19.8005205), P(-10, -19))
};
CGAL::do_curves_intersect(seg.begin(), seg.end());
return 0;
}
Build command:
g++ test.cpp -lgmp -o test
Environment
- Operating system (Windows/Mac/Linux, 32/64 bits): Linux 64bits
- Compiler: g++ (GCC) 11.2.0
- Release or debug mode: Custom (see above)
- Specific flags used (if any): no
- CGAL version: 6.0.1
- Boost version:
- Other libraries versions if used (Eigen, TBB, etc.): GMP 6.2.1
Use Epeck (Exact_predicates_exact_constructions_kernel.h)
Please close
Thank you for your reply.
I'm sorry to bother you, but could you also let me know which option I should use. The following are available for me: "Close as completed", "Close as not planned". The first one doesn't look like appropriate and I can't decide regarding the second one (see below). Possible you could close the issue for me in the right way.
It is not mentioned in the documentation that Epeck should be used. The only requirement is the following:
The robustness of the algorithm is guaranteed if the functions are instantiated with a traits class that employs certified computations. This traits class must be a model of the ArrangementTraits_2 concept
As per ArrangementTraits_2 Concept Reference Arr_segment_traits_2 is a model of the ArrangementTraits_2, so it should be fine to use it in the following way:
#include <vector>
#include <gmp.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_sweep_2_algorithms.h>
int main() {
std::cout << "GMP version: " << gmp_version << std::endl;
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Arr_segment_traits_2<K> T;
typedef T::Point_2 P;
typedef T::Segment_2 S;
std::vector<S> seg = {
S(P(-9.0940291, -20.8188387), P(-10, -19.8005205)),
S(P(-10, -19.8005205), P(-10, -19))
};
CGAL::do_curves_intersect(seg.begin(), seg.end());
return 0;
}
For me the above looks like a documentation bug.
I've found the following Arr_segment_traits_2< Kernel > Class Template Reference:
While selecting an inexact kernel when developing a program usually leads to shorter running times, it causes robustness problems in most cases, and thus renders the program useless.
So documentation is fine, but it is hard to read for one who use the library for the first time: one document says that it is fine to use something and the second one tells you that it won't work.
May I ask you whether it is fine to use Constrained_Delaunay_triangulation_2 with Epick kernel or it will cause issues at some point?
Hello Efi,
Thank you so much for your detailed answer.
Regards,
Ivan