Quantcast

Cell_handle in std::map: Precondition violation

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Cell_handle in std::map: Precondition violation

tholzmann
Hi,

I'm having a (non-constrianed) triangulation and am dividing cells in
several new ones. Therefore, I'm having a mapping from old to new cells:

map<Cell_handle, vector<Cell_handle> > oldToNewCells;

Now I want to check if a cell was already procesed:

vector<Cell_handle> cellAlreadyProcessed;
try{
     cellAlreadyProcessed = oldToNewCells.at(cell);
}
catch(out_of_range){}

This generally works. However, when I compile with -O0, I get this error
in case the cell is not in the mapping:

CGAL ERROR: precondition violation!
Expr: ( i >= 0 && i < 4 ) && ( j >= 0 && j < 4 ) && ( i != j )
File: /home/holzi/tools/CGAL-4.9/include/CGAL/Triangulation_utils_3.h
Line: 67

Could someone explain to me, why this error happens and no out_of_range
exception is thrown?

Thanks!

Thomas


--
====================================================
Dipl.-Ing. Thomas Holzmann
TU Graz - Institut fuer Maschinelles Sehen und Darstellen
Graz University of Technology - Institute for Computer Graphics & Vision
Inffeldgasse 16/II, 8010 Graz, Austria

http://www.icg.tugraz.at/
phone: +43 316 873 5091
====================================================


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cell_handle in std::map: Precondition violation

Laurent Rineau (CGAL/GeometryFactory)
Le Wednesday, January 4, 2017 10:59:46 AM CET Thomas Holzmann a écrit :

> Hi,
>
> I'm having a (non-constrianed) triangulation and am dividing cells in
> several new ones. Therefore, I'm having a mapping from old to new cells:
>
> map<Cell_handle, vector<Cell_handle> > oldToNewCells;
>
> Now I want to check if a cell was already procesed:
>
> vector<Cell_handle> cellAlreadyProcessed;
> try{
>      cellAlreadyProcessed = oldToNewCells.at(cell);
> }
> catch(out_of_range){}
>
> This generally works. However, when I compile with -O0, I get this error
> in case the cell is not in the mapping:
>
> CGAL ERROR: precondition violation!
> Expr: ( i >= 0 && i < 4 ) && ( j >= 0 && j < 4 ) && ( i != j )
> File: /home/holzi/tools/CGAL-4.9/include/CGAL/Triangulation_utils_3.h
> Line: 67
>
> Could someone explain to me, why this error happens and no out_of_range
> exception is thrown?

Why do you think that precondition violation is related to the small code
excerpt you show us?

That exception was triggered because there was a logic error in your code.
Those checks are only applied if the macros CGAL_NDEBUG and NDEBUG are not
defined. That is not related to the optimizations flags -O0, or -O3.
Probably, the way you created the triangulation, or the way your split those
cells invalidated invariant of the triangulation and make it invalid. You can
check the value of `tr.is_valid(true)`, to be sure.

--
Laurent Rineau, PhD
R&D Engineer at GeometryFactory           http://www.geometryfactory.com/
Release Manager of the CGAL Project       http://www.cgal.org/


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cell_handle in std::map: Precondition violation

tholzmann


On 01/04/2017 01:02 PM, Laurent Rineau (CGAL/GeometryFactory) wrote:
>
> Why do you think that precondition violation is related to the small code
> excerpt you show us?
I think it's related to that small code because before that the
triangulation validity is checked. And when my debugger stepped over
this area, the error appeared. However, as my debugger now does very
weird things, I'm not sure about that anymore.
>
> That exception was triggered because there was a logic error in your code.
> Those checks are only applied if the macros CGAL_NDEBUG and NDEBUG are not
> defined. That is not related to the optimizations flags -O0, or -O3.
Ok, then it's strange that this error just happened with -O0 for me...
> Probably, the way you created the triangulation, or the way your split those
> cells invalidated invariant of the triangulation and make it invalid. You can
> check the value of `tr.is_valid(true)`, to be sure.
>
I didn't split anything before that error, and checked validity with
is_valid(true).

However, I currently think that this error is not directly related to
CGAL. So I'll continue debugging :-)

Thanks for the quick answer!

Thoams

--
====================================================
Dipl.-Ing. Thomas Holzmann
TU Graz - Institut fuer Maschinelles Sehen und Darstellen
Graz University of Technology - Institute for Computer Graphics & Vision
Inffeldgasse 16/II, 8010 Graz, Austria

http://www.icg.tugraz.at/
phone: +43 316 873 5091
====================================================


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Loading...