Subject: CGAL users discussion list
List archive
Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3
Chronological Thread
- From: Giles Bathgate <>
- To:
- Subject: Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3
- Date: Mon, 23 Feb 2015 08:19:25 +0000
I have created a demonstration program to illustrate the problem of
throwing an exception from the destructor:
#include <iostream>
using namespace std;
class CGALAssertionException{};
class Supernova{};
class CGALPolyhedron
{
public:
int hello() {
cout << "Hello World!" << endl;
throw new Supernova();
}
~CGALPolyhedron() {
throw new CGALAssertionException();
}
};
void simulation()
{
CGALPolyhedron p;
p.hello();
}
int main()
{
try
{
simulation();
}
catch(...)
{
cout << "Goodbye World!" << endl;
}
}
The program should print Hello Wolrd, then the Supernova exception
gets thrown, and you should get the message Goodbye World!
This is not what happens because of the exception being thrown from
the destructor the program terminates, and this is what we mean by an
Uncatchable exception.
Your fix (which would be to stop the Supernova exception being thrown
in the first place) is valid, that's actually what we want in both
openscad and rapcad.
My solution tries to make the code generally more robust, by only
throwing an exception from the destructor, if we are not already in an
exception unwinding the stack.
e.g in the destructor
if (!uncaught_exception())
throw new CGALAssertionException();
Regards,
Giles
On 23 February 2015 at 07:13, Sebastien Loriot (GeometryFactory)
<>
wrote:
> On 02/20/2015 09:01 PM, Marius Kintel wrote:
>>
>> On Feb 20, 2015, at 14:55 PM, Sebastien Loriot (GeometryFactory)
>> <>
>> wrote:
>>>
>>> In the meantime you can try:
>>> #define CGAL_CT2_WANTS_TO_HAVE_EXTRA_ACTION_FOR_INTERSECTING_CONSTRAINTS
>>> #define CGAL_CDT2_EXTRA_ACTION_FOR_INTERSECTING_CONSTRAINTS throw
>>> WhatEverException;
>>>
>>> This will allow you to throw an exception if constraints intersect.
>>>
>> Not sure that would make a difference. If those defines are not there, the
>> default action is "CGAL_triangulation_assertion(false);”
>> ..which throws an exception. The presence of this exception is what causes
>> the later crash.
>>
>> My understanding is that what we need is to _not_ throw _any_ exceptions
>> in destructors, as that requires a guarantee that no existing exceptions
>> can
>> be active. Such a guarantee is probably hard or tedious to maintain.
>
>
> With the patch for Nef, I don't have any exception thrown in the destructor
> anymore in the polyhedron demo.
> If you have an issue triangulating an invalid face, then if you throw
> an exception using the macros I mentioned it should be OK if you protect
> your call to Nef_polyhedron_3::convert_to_polyhedron with a try/catch.
>
> Maybe I'm missing something here...
>
> Sebastien.
>
>
>>
>> -Marius
>>
>>
>
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://sympa.inria.fr/sympa/info/cgal-discuss
>
>
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, kintel, 02/17/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Sebastien Loriot (GeometryFactory), 02/18/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Giles Bathgate, 02/18/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Sebastien Loriot (GeometryFactory), 02/19/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Marius Kintel, 02/20/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Sebastien Loriot (GeometryFactory), 02/20/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Marius Kintel, 02/20/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Giles Bathgate, 02/20/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Sebastien Loriot (GeometryFactory), 02/23/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Giles Bathgate, 02/23/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Marius Kintel, 02/20/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Sebastien Loriot (GeometryFactory), 02/20/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Marius Kintel, 02/20/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Sebastien Loriot (GeometryFactory), 02/19/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Giles Bathgate, 02/18/2015
- Re: [cgal-discuss] Uncatchable exception converting from Nef polyhedron to Polyhedron_3, Sebastien Loriot (GeometryFactory), 02/18/2015
Archive powered by MHonArc 2.6.18.