Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] segmentation fault insert_at_vertices

Subject: CGAL users discussion list

List archive

[cgal-discuss] segmentation fault insert_at_vertices


Chronological Thread 
  • From: Mateus Bellomo <>
  • To:
  • Subject: [cgal-discuss] segmentation fault insert_at_vertices
  • Date: Sat, 19 Dec 2015 12:29:21 -0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:AtD8rxF5gz7lfvCyV3ow051GYnF86YWxBRYc798ds5kLTJ75pMWwAkXT6L1XgUPTWs2DsrQf27SQ6/iocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC0YLvj6ibwN76XUZhvHKFe7R8LRG7/036l/I9ps9cEJs30QbDuXBSeu5blitCLFOXmAvgtI/rpMYwu3cYh/V0/MFJVeD2fr8zUKdDJDUgKWE8osPx5jfZSg7aw3IAX3gN2jBFBwzC6RayCpL4ribnreBw3C2dOMreQrU9WDDk5KBuHky7wBwbPiI0pTmEwvd7i7hW9Uqs

Hello,

I'm making a program to generate a rectangular grid using Arrangement_2. I've finished the algorithm and it was working well but in the future I'll have to use a function that is present only in CGAL-4.7 so I've purged my cgal installation and got the CGAL-4.7.

After that the same program that was working before start to get Segmentation Fault. I think the lines 56 and 73 (both commented) are causing the Segmentation Fault. The program and input are attached.

Anyone knows if there is some major difference in this version of CGAL that is causing this error?

Thanks.

Mateus

Attachment: test.opt
Description: Binary data

#include <CGAL/Cartesian.h>
#include <CGAL/Quotient.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arr_polyline_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_extended_dcel.h>
#include <bits/stdc++.h>


#define EPS 1e-3
#define pb push_back

using namespace std;

typedef CGAL::Quotient<CGAL::MP_Float>                  Number_type;
typedef CGAL::Cartesian<Number_type>                    Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel>              Segment_traits_2;
typedef CGAL::Arr_polyline_traits_2<Segment_traits_2>   Traits_2;
typedef Traits_2::Point_2                               Point_2;
typedef Traits_2::Curve_2                               Polyline_2;

typedef CGAL::Arr_extended_dcel<Traits_2, int, bool, int>      Dcel;
typedef CGAL::Arrangement_2<Traits_2, Dcel>                Ex_arrangement_2;
typedef Segment_traits_2::X_monotone_curve_2               XSegment_2;
typedef Ex_arrangement_2::Vertex_handle                    Vertexh;


double MAXx, MAXy;
int ncols, nlines, totalNumberOfPoints;
Ex_arrangement_2 arr;


int main (){

  srand(time(NULL));

  // read arrangement of file
  ifstream infile("test.opt");
  infile >> nlines >> ncols;
  infile >> MAXx >> MAXy;
  infile >> totalNumberOfPoints;

  double gapcols = MAXx/(1.0*ncols+1);
  double gaplines = MAXy/(1.0*nlines+1);

  /* Make a regular grid in arrangement */
  vector<Vertexh> prevline;
  double y = 0.0;
  for(int i = 0; i < nlines+2; i++, y += gaplines){
    Point_2 p(0.0, y);
    Vertexh v = insert_point(arr, p);

    if(i != 0){
      XSegment_2 h(v->point(), prevline[0]->point());
      // arr.insert_at_vertices(h, v, prevline[0]);
    }

    vector<Vertexh> currline;
    currline.pb(v);
    double x = gapcols;
    for(int j = 1; j < ncols+2; j++, x += gapcols){
      Point_2 q(x, y);
      XSegment_2 s(p,q);

      Vertexh u = insert_point(arr,q);
      currline.pb(u);

      arr.insert_at_vertices(s,u,v);

      if(i != 0){
      	XSegment_2 h(u->point(), prevline[j]->point());
      // 	arr.insert_at_vertices(h,u,prevline[j]);
      }

      p = q;
      v = u;
    }
    prevline.clear();
    prevline = currline;
  }

  /* Insert points in arrangement. */
  for(int i = 0; i < totalNumberOfPoints; i++){
    int w;
    double x,y;
    infile >> w >> x >> y;

    Point_2 p(x, y);
    Vertexh v = insert_point(arr, p);
    v->set_data(w);
  }

  for(int i = 0; i < nlines+2; i++)
    for(int j = 0; j < ncols+2; j++){
      double x,y;
      infile >> x >> y;
    }

  cout << "faces = " << arr.number_of_faces() << endl;
  cout << "vertices = " << arr.number_of_vertices() << endl;
  cout << "edges = " << arr.number_of_edges() << endl;
  cout << "-----------------------------------------" << endl;


  return 0;
}



Archive powered by MHonArc 2.6.18.

Top of Page