Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Add information in Triangulation while inserting a range of points

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Add information in Triangulation while inserting a range of points


Chronological Thread 
  • From: Andreas Fabri <>
  • To:
  • Subject: Re: [cgal-discuss] Add information in Triangulation while inserting a range of points
  • Date: Mon, 13 May 2019 10:10:35 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=None ; spf=None
  • Ironport-phdr: 9a23:MJaHBxWfCHEN8g2bF8OcgFfVLuLV8LGtZVwlr6E/grcLSJyIuqrYbRCFt8tkgFKBZ4jH8fUM07OQ7/m5Hz1bqs/b6zgrS99lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUhrwOhBoKevrB4Xck9q41/yo+53Ufg5EmCexbal9IRmrsAndrM0bjIVtJqos1BfErGZDdvhLy29vOV+dhQv36N2q/J5k/SRQuvYh+NBFXK7nYak2TqFWASo/PWwt68LlqRfMTQ2U5nsBSWoWiQZHAxLE7B7hQJj8tDbxu/dn1ymbOc32Sq00WSin4qx2RhLklDsLOjgk+2zRl8d+jr9UoAi5qhJi3YDUboGbOvlwcKzTctwVR3ZOU91LWCBdGI6xdZcDAuQDMOtesoLzp0EOrRy7BQS0GO7vzCJHhmXo0qIgyOQqDAHI0xY7ENIUsXTfsdL4O70UUe+o1qnH0y/Mb+hM1Tfz8ofHaQohofCXULJ/b8XRzkwvGB3ZjlWKqY3lMSma2fgRs2ic9ephVfijhHIgqwF0uzWiwNonhIfOhoIQ0F/E9CN5zZ4zJdKiU0F0etqkH4VKuy6GMIt2R9suQ2BuuCYgy70Jo4S3fCYQyJg/2xHfZOaIc4yS7hLkTuaRLjF1j29mdrKnnxu+7Eqtx+7mWsS63ltGtDRJn9nRunwXyhDe7tCLR/9h8ku72juC1hrf5vxALE0wj6bXNpAsz7A2m5EOq0rMBDX2l1/zjKKOdkUr5Oyo6+P/b7n7qZKQLYp0igb8P6g0n8ywG+U4MgwXU2ic5OS8yKfv/UrnQLVKlPE2lLfWsIzCKcQaoK62HRNV354+5xu9DDqqytoVkHcdIF5beB+LkpLlN0zKLfzgCPewmVWskDNlx/DcOb3hB43AIWLFkLj8Z7Zy9VRTyBEpwdBR/Z1bEasBIPPoV0/+qtPYCRo5PBKow+b9CNR92JkRVn6TAq+eKqPTsUWE6f4oI+mJfIMVoiryK+A55/7yin80gUMSfaaz0psTcXy3A/VmI16FbnrxmdcBCnwHvhE+TezvkF2NSyRfZ3e0X6Im5zE0EpiqDYnZRtPlvbqawS3uHoFKfnsUTReXAHLwfsOFXe0NYWScOIh6gzkcXP+gTYEmkhqhvQu/x7t8JffP4X4kssfo29FxouHSjhov7idcDsKH0mjLQXsnsHkPQmof2qxlrEVmgnmK27J5y6hRE9BJ6vpSFAkzP4Td5+N3DNX/RhjQcN6CVFG8U5OtBjRnHYF5+MMHf0soQ4bqtRvExSf/W+ZJxYzOP4Q99+fn51a0P9x0kS+U26QmilQ6WNpBPGa6gbRusQPUAtyRyhjLp+ORba0ZmRX12iKDwG6J5hwKCVI2VKKaG3UWZ0+TqsnloETcT/moBKh1alIQm/7HEbNDb5jStXsDQf7iPNrEZGfrwjW/CBGNy6+WfYTjcHkaxjSbA08BwVge


We could add an insertion of a range to the Triangulation_3 class, but then no
reshuffling of the points should happen as the insertion order implies which
triangles you have.  This is different for the Delaunay/Regular triangulation
where the resulting triangulation is unique, that is independent from the
insertion order.

andreas


On 5/13/2019 9:01 AM, Marc Alexa wrote:
Yes, CGAL is sometimes mysterious in what types are accepted by what functions. I agree you’d expect that the insert method for Triangulation_3 should be able to understand how to handle the pairs if Delaunay_triangulation_3 does. But, no. If you insist on using the pairs and are ok with initially getting a Delaunay triangulation, the following code works just fine:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Triangulation_3.h> #include <CGAL/Delaunay_Triangulation_3.h> #include <CGAL/Triangulation_cell_base_3.h> #include <CGAL/Triangulation_vertex_base_with_info_3.h> #include <vector> typedef CGAL::Exact_predicates_inexact_constructions_kernel         K; typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned, K>    Vb; typedef CGAL::Triangulation_cell_base_3<K>                 Cb; typedef CGAL::Triangulation_data_structure_3<Vb, Cb>                Tds; //Use the Fast_location tag. Default or Compact_location works too. typedef CGAL::Triangulation_3<K, Tds> Triangulation; typedef CGAL::Delaunay_triangulation_3<K, Tds> DT; typedef Triangulation::Point Point; int main() { std::vector< std::pair<Point, unsigned> > points; points.push_back(std::make_pair(Point(0, 0, 0), 0)); points.push_back(std::make_pair(Point(1, 0, 0), 1)); points.push_back(std::make_pair(Point(0, 1, 0), 2)); points.push_back(std::make_pair(Point(0, 0, 1), 3)); points.push_back(std::make_pair(Point(2, 2, 2), 4)); points.push_back(std::make_pair(Point(-1, 0, 1), 5));
    Triangulation T = DT(points.begin(), points.end());
    CGAL_assertion(T.number_of_vertices() == 6); return 0; }
I believe speed-wise there is very little to be gained from not using Delaunay. If you don’t care about what coordinate in space carries which number, you could insert the range of points first and then set the info later. In this case, however, the order of the points you get form the vertex iterator will likely differ from the order in which you provided the points. 


-Marc


On 13. May 2019, at 04:25, sanlingtonCGAL <> wrote:

Hi,

I know the Delaunay and Regular triangulation in CGAL can already add
information to vertices while inserting /a range of points/, as introduced
in
https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation_3Delaunay
But it seems that the Triangulation_2/3 (not Delaunay triangulation or
Regular triangulation) can't do that, am I correct?
What I want to do is to construct Triangulation by inserting a range of
points, and each point or vertex would carry extra information, like an
index.
I am using codes like:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Triangulation_3.h>
#include <CGAL/Triangulation_cell_base_3.h> #include <CGAL/Triangulation_vertex_base_with_info_3.h> #include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel         K;
typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned, K>    Vb;
typedef CGAL::Triangulation_cell_base_3<K>                 Cb;
typedef CGAL::Triangulation_data_structure_3<Vb, Cb>                Tds;
//Use the Fast_location tag. Default or Compact_location works too.
typedef CGAL::Triangulation_3<K, Tds> Triangulation;
typedef Triangulation::Point                                            
Point;
int main()
{
std::vector< std::pair<Point, unsigned> > points; points.push_back(std::make_pair(Point(0, 0, 0), 0));
points.push_back(std::make_pair(Point(1, 0, 0), 1));
points.push_back(std::make_pair(Point(0, 1, 0), 2));
points.push_back(std::make_pair(Point(0, 0, 1), 3));
points.push_back(std::make_pair(Point(2, 2, 2), 4));
points.push_back(std::make_pair(Point(-1, 0, 1), 5));

Triangulation T(points.begin(), points.end());
CGAL_assertion(T.number_of_vertices() == 6);
return 0;
}

The above codes are similar to those in the manual document, I just replaced
the Delaunay with Triangulation. But the compiler gave me errors like:

c:\program files (x86)\microsoft visual
studio\2017\community\vc\tools\msvc\14.16.27023\include\xmemory0(881): error
C2664: 'CGAL::Point_3<Kernel_>::Point_3(CGAL::Point_3<Kernel_> &&)': cannot
convert argument 1 from '_Ty' to 'const CGAL::Origin &'
1>        with
1>        [
1>            Kernel_=CGAL::Epick
1>        ]
1>        and
1>        [
1>            _Ty=std::pair<Point,unsigned int> 1>        ]
1>c:\program files (x86)\microsoft visual
studio\2017\community\vc\tools\msvc\14.16.27023\include\xmemory0(879): note:
Reason: cannot convert from '_Ty' to 'const CGAL::Origin'
1>        with
1>        [
1>            _Ty=std::pair<Point,unsigned int> 1>        ]


What should I do to add information to point/vertex of a Triangulation while
inserting a range of points?

Thank you.





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


-- 
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912    skype: andreas.fabri



Archive powered by MHonArc 2.6.18.

Top of Page