Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Add vertex info before inserting constraints

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Add vertex info before inserting constraints


Chronological Thread 
  • From: "Marsh, Chris" <>
  • To: "" <>
  • Subject: Re: [cgal-discuss] Add vertex info before inserting constraints
  • Date: Fri, 12 Apr 2019 17:01:59 +0000
  • Accept-language: en-CA, en-US
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=Pass
  • Ironport-phdr: 9a23:TJ9IthH22ssCKO7fJJewu51GYnF86YWxBRYc798ds5kLTJ76p8+9bnLW6fgltlLVR4KTs6sC17OP9fq5EjxbqdbZ6TZeKcQKD0dEwewt3CUYSPafDkP6KPO4JwcbJ+9lEGFfwnegLEJOE9z/bVCB6le77DoVBwmtfVEtfre9FYHdldm42P6v8JPPfQpImCC9YbRvJxmqsAndrMYbjZZ/Jqor1BfFv3REdudYyGh1IV6fgwvw6t2/8ZJ+7yhcoe4t+9JFXa7nY6k2ULtUASg8PWso/sPrrx7DTQWO5nsYTGoblwdDDhbG4h/nQJr/qzP2ueVh1iaUO832Vq00Vi+576h3Uh/oiTwIOCA//WrKl8F/lqNboBampxxi347ZZZyeOfRicq/Be94RWGxMVdtTWSNcGIOxd4sBAfQcM+ZEoYfzpFUOohm/BQawC+zi0SVHimPs0KAgz+gtDQPL0Qo9FNwOqnTUq9D1Ob8cXe6y1qbI1y7Db/NO1Tzg9oXIcgohofCXXb5+bMHczlUgFwPfjlWRsozpJTaV2f4Xs2iA7+ptTv+vi3U9pAFqoTij3NsjhZPQi48T11vK+yJ5wIMvKt25Tk52edikH4FLuC6BM4t5XNkuTH1vuCY/0rEGuJi7fDILyJs93RLfZeaHf5CU7RLsTumRJS10hHV/eLKwgRu57EuuyvXkW8S7zFpGtDdJnsXOu3wX1hHe6NKLRuZz80u9wTqDyRzf5+VeLU03lafXMYMtz78xm5YJvknOEDf6mEvog6KVakkp/+2l5/nob7jluJCRMo55hwPjPakqn8G/D/83PwoOUmWe5+ux27Pu8En/Tb5XlPM5iLPZv4rfJckDpq62HQtV0oE75huhEzqoyMgUkWQeIFxbYRyLkpHlO1bVL//mF/u/hEmskCtwyPDBI73hBIjCImLbkLf7erZ991BTxxYvzdBe4JJUDKsNIPXuWk/tsNzYCRg5Mw+uz+n7D9V905sSWWOJAqCHLKPfqVCF6v41L+WReIMYuizxJvkn6vL0kHM0l0MRcbGs3ZQNaXC4GvpmI1+eYXrpmtoODWcKvhA/TOzxklGCVCRcZ2ypX6I8/Tw7FZmmAp3YRoCumrCOwD20EoVMZm9aElCMDWvod4KcVvgQZyKdOMthniUZWrigUI8uyQyutBThy7d8NerV+igYtYr529Rv5u3Tkwsy9T1uAMiH3WGNVTI8o2UTWjVj3LxjuVcvjRCYwK1girpZE8ZS7rVHSEAhJJvExqt7Dd71HQnOd9PMRFe9Sci9GmINSYd7yNAHZwNxGs6pkwvY9yusGb4c0bKRTtRg+a3V2z39Jt121m3d/KgnlVgvBMVVYz6InKl6okL2DpTSkwHRvKawdL9WlHrG9H2C1iyLtVtDUCZtSqzeXjYUbx2F/pzC+kreQur2WvwcOQxbxJvac/YYWpjSlVxDAczbFpHebma2xzjiLj+unurJUK2zPmIX0WPaFVQOlB0V8TCeLw8iCyy9omXYSjtzCVboZECq+u57+iriEh0EijqSZkgk7IKbvwYPjKXEGe4I16kH/iwo+W0tTQSNmunOAt/FnDJPOaBVYNcz+lBCjDqLqhd0JZ/mJKkw31M=

insert_constraint takes 2 points or vertex handles, and sets an edge between the two to be a constraint.

These constraint vertexes will exist in the triangulation, so just insert them as normal, and obtain a handle to them.

// these will be your constraints
Vertex_handle vh = cdt.insert(Point(x,y)); // can insert with info or whatever
Vertex_handle vh1 = cdt.insert(Point(x1,y1));

and then you can insert the constraint
cdt.insert_constraint(vh,vh1);

I do it this way as I'm reading in points from a file. I'm unsure how you obtain the vertex handles if you use the .begin(), .end() insertion approach you showed. But this should get you started at least.

Cheers
Chris


On Fri, Apr 12, 2019 at 1:08 AM malcolm <> wrote:
Hi,
I am using the Constrained_Delaunay_triangulation_2 class. I want to attach
vertex info to the constraint vertices before calling insert_constraint, in
the same way as I can add info to vertices before inserting in a
triangulation. I cannot find a CGAL method to do this. Here's my code

#include <CGAL\Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>

#include <vector>

class VertexInfo
{
public:
        double data;
        int index;

        VertexInfo() {}
        VertexInfo(double e, int i)
                :data(e), index(i) {}
};

typedef CGAL::Exact_predicates_inexact_constructions_kernel               
Kernel;
typedef CGAL::Exact_predicates_tag                                                  Itag;
typedef CGAL::Triangulation_vertex_base_with_info_2<VertexInfo, Kernel> Vb;
typedef CGAL::Constrained_triangulation_face_base_2<Kernel>                 Fb;
typedef CGAL::Triangulation_data_structure_2<Vb, Fb>                         
Tds;
typedef CGAL::Constrained_Delaunay_triangulation_2<Kernel, Tds, Itag>   
Delaunay;
typedef Kernel::Point_2                                                                   
CGAL_Point;

int main()
{
        Delaunay T;
        std::vector< std::pair<CGAL_Point, VertexInfo> > points;
        points.push_back(std::make_pair(CGAL_Point(0.123456789, 0), VertexInfo(0.3,
-1)));
        points.push_back(std::make_pair(CGAL_Point(1, 0), VertexInfo(0.5, -1)));
        points.push_back(std::make_pair(CGAL_Point(0, 1), VertexInfo(1.3, -1)));
        points.push_back(std::make_pair(CGAL_Point(1, 1), VertexInfo(0.8, -1)));
        points.push_back(std::make_pair(CGAL_Point(2, 2), VertexInfo(0.3, -1)));

        // Triangulate
        T.insert(points.begin(), points.end());

        std::vector< std::pair<CGAL_Point, VertexInfo> > constraintPts;
        constraintPts.push_back(std::make_pair(CGAL_Point(10, 10), VertexInfo(1.3,
0)));

        // how do I add constraints with vertex just like above?
        T.insert_constraint(constraintPts.begin(), constraintPts.end()); // this
gives a compiler error

        return 0;
}

If this is not possible, I would like to get the vertex handles of the
constrained vertices and then attach the vertex info to each vertex. Is this
possible?



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

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