Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] mesh 2d with intersecting constraints seg faults while calling method refine_mesh()

Subject: CGAL users discussion list

List archive

[cgal-discuss] mesh 2d with intersecting constraints seg faults while calling method refine_mesh()


Chronological Thread 
  • From: Fabio Romani <>
  • To:
  • Subject: [cgal-discuss] mesh 2d with intersecting constraints seg faults while calling method refine_mesh()
  • Date: Wed, 15 Mar 2017 09:32:23 -0700
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:Nx60PBX5W2z+grTag3+23h4rThjV8LGtZVwlr6E/grcLSJyIuqrYZRODt8tkgFKBZ4jH8fUM07OQ6PG9HzFQqsbe+DBaKdoXCE9D0Z1X1yUbQ+e7SmTDZMbwaCI7GMkQHHRExFqcdXZvJcDlelfJqWez5zNBUj/2NA5yO/inUtWK15f/hKiO/MjYbAxMwTa8erhvNw6erAPLt8BQj5ExBLw2z07nq3FJfKxswmZhI1Pbyxrm/du9/Zg8qgxfvvsg84hLVqCsLPdwdqBREDlzazN938bsrxSWFQY=

Hi,

 

Pretty new with CGAL coding. I'm trying to mesh shapes on different layers that could intersect each other.


I'm using this header file to setup my space:

#ifndef MESH_H

#define MESH_H


#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

#include <CGAL/Constrained_Delaunay_triangulation_2.h>

#include <CGAL/Delaunay_mesher_2.h>

#include <CGAL/Delaunay_mesh_face_base_2.h>

#include <CGAL/Delaunay_mesh_vertex_base_2.h>

#include <CGAL/Delaunay_mesh_size_criteria_2.h>

#include <CGAL/lloyd_optimize_mesh_2.h>

#include <iostream>

#include <fstream>

#include <sstream>

#include <vector>

#include <list>

#include <string>

//#include <CGAL/Cartesian.h>


using namespace std;


typedef CGAL::Exact_predicates_inexact_constructions_kernel K;

//typedef CGAL::Triangulation_vertex_base_2<K> Vb;

typedef CGAL::Delaunay_mesh_vertex_base_2<K>                Vb;

typedef CGAL::Delaunay_mesh_face_base_2<K>                  Fb;

typedef CGAL::Triangulation_data_structure_2<Vb, Fb>        Tds;

typedef CGAL::Exact_predicates_tag                          Itag;

typedef CGAL::Constrained_Delaunay_triangulation_2<K, Tds, Itag>  CDT;

typedef CGAL::Delaunay_mesh_size_criteria_2<CDT>            Criteria;

typedef CGAL::Delaunay_mesher_2<CDT, Criteria>              Mesher;


typedef CDT::Vertex_handle Vertex_handle;

typedef CDT::Point         Point;

//typedef CGAL::Point_2<CGAL::Cartesian<double> >  Point;


class Mesh {

    CDT cdt;

    list< vector<Vertex_handle> > polygons;

    vector<Vertex_handle> polygon;

    // seeds are points that falls inside holes in the polygons

    // this is the way that the algorithm knows how to avoid

    // filling the holes

    std::list<Point> list_of_seeds;


public:

    Mesh();

    ~Mesh();

    Vertex_handle add_point(Point point);

    void add_constraint(Vertex_handle va, Vertex_handle vb);

    void add_seed(Point point);

    long n_vertices();

    Mesher run(Criteria criteria = Criteria(), bool optimize = false);

    void export_triangles_points(std::ofstream &cf, Mesher mesher);

    void read_polygons(ifstream &cf);


    bool import_database(ifstream &cf);

};


and this method to import my points:


void

Mesh::read_polygons(ifstream &cf)

{

    // type == [polygon, hole, point]

    string type, layer, net;

    int    npoly = 0, nhole = 0, npoint = 0;

    while(cf >> type)

    {

        unsigned long int n;

        if( type == "polygon" )

        {

            polygon.clear();

            // reading layer

            cf >> layer;

            // reading net

            cf >> net;

            // reading number of points

            cf >> n;

            cout << "*INFO* Importing polygon #" << ++npoly << " (" << n << " vertices)" << endl;

            while( n-- )

            {

                Point p;

                cf >> p;

//                p.add_property_map<Vertex_handle, string>().first;

                polygon.push_back(cdt.insert(p));

            }


            // adding constraints

            for( int i = 1; i < polygon.size(); i++ )

            {

                cdt.insert_constraint(polygon[i-1], polygon[i]);

            }

            cdt.insert_constraint(polygon[polygon.size()-1], polygon[0]);

        }

        else if( type == "point" )

        {

            cout << "*INFO* Importing point #" << ++npoint << endl;

            Point p;

            cf >> p;

            cdt.insert(p);

        }

        else

        {

        }

    }

}



and then I just run the mesher:


Mesher

Mesh::run(Criteria criteria, bool optimize)

{

    Mesher mesher(cdt);

    mesher.set_criteria(criteria);

    cout << "HEREEEEEEE" << endl;

    mesher.refine_mesh();

    if( optimize )

    {

        cout << "*INFO* Running lloyd optimizer..." << endl;

        // optimizing mesh

        CGAL::lloyd_optimize_mesh_2(cdt, CGAL::parameters::max_iteration_number = 10);

    }

    return mesher;

}


everything works ok if I don't have intersecting constraints...but at times I do and the program just seg faults.


According to the documentation online, CGAL should support intersecting constraints, so it could be just a matter of me not setting the CDT template properly.


Any help appreciated!


Thank


--
Fabio



Archive powered by MHonArc 2.6.18.

Top of Page