Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation


Chronological Thread 
  • From: Pol Monsó Purtí <>
  • To:
  • Subject: Re: [cgal-discuss] Limiting the maximum length of an edge in a Delaunay triangulation
  • Date: Wed, 29 Jun 2016 16:52:32 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:XhirGBOpx09AAgqtMjYl6mtUPXoX/o7sNwtQ0KIMzox0KPX7rarrMEGX3/hxlliBBdydsKMczbOL+P+5EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6anHS+4HYoFwnlMkItf6KuS9aU1pn8iLn60qaQSj0AvCC6b7J2IUf+hiTqne5Sv7FfLL0swADCuHpCdrce72ppIVWOg0S0vZ/or9YwuxlWoO8ros5cTb3hLeN/Vq1dFD1gMmYv5cStuwOEVhqK/nJbU2MYlV1DDAHBqR37RZzsqTCpiu0o0yaTOYj6TKs/RC+5x6ZtUh7hzikdZBAj92SCsst0xIdcpgk67yRi2ZJRKNWRMOd4d+Xbes0TbWVEV8dVESdGB9XvPMM0E+MdMLMA/MHGrFwUoE7mCA==

post scriptum:

I believe the refine works as expected, because the triangles in the populated area are quite nice.  But then this approach is not useful to limit the length of the edges. Ideally I'd prefer those vertices to connect with the infinite vertex rather than make this long edges.

Somebody know how to achieve this correctly? I can provide a MWE and sample data if somebody is interested.

On Wed, Jun 29, 2016 at 4:34 PM, Pol Monsó Purtí <> wrote:
Hello Laurent,

Sorry for the late reply, I've quickly tried what you've suggested right now, to no avail. I've added 4 vertices that contain the others and then called refine. The number of faces and vertices is the same and all faces are outside the domain.

I still feel I'm doing something wrong.

An excerpt of the relevant code:


typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Projection_traits_xy_3<K>  Gt;
typedef K::Point_3   Point3;

typedef CGAL::Triangulation_vertex_base_2<Gt> Vb;
typedef CGAL::Delaunay_mesh_face_base_2<Gt> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
//TODO check wether Exact_intersections_tag is more appropriate
typedef CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds, CGAL::Exact_predicates_tag> CDTb;
typedef CGAL::Constrained_triangulation_plus_2<CDTb> CDT; //handles breaklines intersections
typedef CGAL::Delaunay_mesh_size_criteria_2<CDT> Criteria;

typedef CDT::Vertex_handle Vertex_handle;
typedef CDT::Point Point;

[...]
int QD::triangulate(const std::vector<cgal_utils::Point>& points,
                           const std::vector<std::vector<cgal_utils::Point>>& breaklines,
                           cgal_utils::CDT& cdt,
                           const bool& saveTriangulation,
                           const fs::path& outdir,
                           const fs::path& outfname)
{
    std::cout << "Start triangulation" << std::endl;

    //constraints
    for( std::vector<Point> breakline : breaklines)
    {
        for(unsigned int i=0; i < breakline.size()-1; i++)
        {
            cdt.insert_constraint(breakline[i], breakline[i+1]);
        }
    }

    cdt.insert(points.begin(), points.end());
    double margin = 50;

    cgal_utils::Point bbul(727250.0 - margin, 6880620.0 + margin, 0.0);
    cgal_utils::Point bbbl(bbul.x(), bbul.y() - 20000.0 - margin, 0.0);
    cgal_utils::Point bbur(bbul.x() + 17000.0 + margin, bbul.y(), bbul.z() + 200.0 + margin);
    cgal_utils::Point bbbr(bbul.x() + 17000.0 + margin, bbul.y() - 20000.0 - margin, bbul.z() + 200.0 + margin);

    cdt.insert(bbul);
    cdt.insert(bbbl);
    cdt.insert(bbur);
    cdt.insert(bbbr);

    std::cout << "Bounding box: " << bbul << " " << bbbr << std::endl;

    std::cout << "Refining the " << cdt.number_of_vertices() << " vertices." << std::endl;

    std::cout << "Number of points and faces of CDT: "
              << cdt.number_of_vertices() << " " << cdt.number_of_faces() << std::endl;

    CGAL::refine_Delaunay_mesh_2(cdt, Criteria(0.1, 0.1));

    std::cout << "Number of points and faces of CDT: "
              << cdt.number_of_vertices() << " " << cdt.number_of_faces() << std::endl;

    if(saveTriangulation)
    {
        fs::path outoff(outdir);
        outoff /= outfname;
        outoff.replace_extension(".off");

        std::ofstream outstream1(outoff);
        if(!outstream1)
        {
            std::cerr << "error writing to " << outoff << std::endl;
            return EXIT_FAILURE;
        }

        outstream1 << std::fixed << std::setprecision(4) ;

        outstream1 << "OFF\n"  << cdt.number_of_vertices()
                   << " "  << cdt.number_of_faces() << " 0" << std::endl;

        std::map<CDT::Vertex_handle,int> indices;
        int counter = 0;

        for(CDT::Finite_vertices_iterator it = cdt.finite_vertices_begin();
            it != cdt.finite_vertices_end(); ++it)
        {
          //K::Point_3 p = it->point();
          //outstream1 << p.x() << " " << p.y() << " " << p.z() << std::endl;
          outstream1 << it->point() << std::endl;
          indices.insert(std::pair<CDT::Vertex_handle,int>(it, counter++));
        }

        for(CDT::Finite_faces_iterator it = cdt.finite_faces_begin(); it != cdt.finite_faces_end(); ++it)
        {
            bool indomain = it->is_in_domain();
            if(!indomain)
            {
                outstream1 << "3 " << indices[it->vertex(0)]
                           << " "  << indices[it->vertex(1)]
                           << " "  << indices[it->vertex(2)] << std::endl;
            }
        }

        std::cout << "Saved triangulation at " << outoff << std::endl;
    }
    return 0;
}



On Fri, Jun 10, 2016 at 6:00 PM, Laurent Rineau (CGAL/GeometryFactory) <> wrote:
Le Friday 10 June 2016 17:28:46 Pol Monsó Purtí a écrit :
> Hello Laurent, thank you for your interest,
>
> *All* the faces are said to be outside the domain, not only those long
> faces. Otherwise I'd be done by checking wether it is in or out. Should I
> check that my cdt constitutes indeed a *planar straight line graph *? Is it
> possible it doesn't at all?

I suggest you insert in the CDT a closed polygon with four vertices, a "box",
that contains all the other ones. That way, you will be sure that everything
is inside the domain bounded by that box.

--
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







Archive powered by MHonArc 2.6.18.

Top of Page