CGAL alpha shape example - segmentation fault

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

CGAL alpha shape example - segmentation fault

irene89
Hi everybody, I'm new to C++ and CGAL. I'm tryng to obtain an alpha shape from a point set in the plane and to do that I was first trying to run the following example:

http://doc.cgal.org/latest/Alpha_shapes_2/Alpha_shapes_2_2ex_alpha_shapes_2_8cpp-example.html

with this set of point:
(0,2), (-0.5,1), (0,1), (0.5,1), (-2,0), (-1,0), (0,0), (1,0), (2,0), (-0.5,-1), (0,-1), (0.5,-1), (0,-2)

The points are saved in a file data.txt with the same exact format above and this file is in the same directory of the .cpp. Obviously I changed the line in the example

  std::ifstream is("./data/fin", std::ios::in);

with the line

  std::ifstream is("data.txt", std::ios::in);

I compiled with
g++ prova.cpp -lCGAL -lgmp
and all went ok, but when I run it I had this error:

Reading 0 points from file
Alpha Shape computed
0 alpha shape edges
Segmentation fault (core dumped)

Any idea?
Thanks in advance for helping!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CGAL alpha shape example - segmentation fault

Marc Glisse
On Sun, 20 Nov 2016, irene89 wrote:

> Hi everybody, I'm new to C++ and CGAL. I'm tryng to obtain an alpha shape
> from a point set in the plane and to do that I was first trying to run the
> following example:
>
> http://doc.cgal.org/latest/Alpha_shapes_2/Alpha_shapes_2_2ex_alpha_shapes_2_8cpp-example.html
>
> with this set of point:
> (0,2), (-0.5,1), (0,1), (0.5,1), (-2,0), (-1,0), (0,0), (1,0), (2,0),
> (-0.5,-1), (0,-1), (0.5,-1), (0,-2)
>
> The points are saved in a file data.txt with the same exact format above and
> this file is in the same directory of the .cpp. Obviously I changed the line
> in the example
>
>  std::ifstream is("./data/fin", std::ios::in);
>
> with the line
>
>  std::ifstream is("data.txt", std::ios::in);

Did you look at the file data/fin that you are replacing? It is formatted
completely differently from your file...
"Reading 0 points from file" is a strong hint that you need to take a
closer look at the file. It should look like:

13
0 2
-0.5 1
...

--
Marc Glisse

--
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: CGAL alpha shape example - segmentation fault

irene89
Formatting the data like you said, it works! Thanks a lot!
I was not looking at the function file_input and that's why I did not get the error.. I'm sorry.
Loading...