Subject: CGAL users discussion list
List archive
- From: Nafnlaus <>
- To:
- Subject: [cgal-discuss] Unexpected behavior, where I can get anything to work at all.
- Date: Sun, 21 Dec 2014 15:54:36 -0800 (PST)
So, my goal for using CGAL is to convert point clouds into meshes. The points
are 3d and carry information (at this point, just an index, but there will
be more in the future); both a 3d triangulation or a 2d triangulation of 3d
points are acceptable.
Of the many possibilities CGAL offers for this, I've only gotten one to
"work". And it doesn't at all work in the way that I expected or wanted.
-----------------------------
#include <iostream>
#include <vector>
#include <string>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_with_info_3<int, K> Vb;
typedef CGAL::Triangulation_data_structure_3<Vb> Tds;
typedef CGAL::Delaunay_triangulation_3<K, Tds> Triangulation;
typedef Triangulation::Point Point;
int main(int argc, char** argv)
{
std::vector<Point> points;
points.push_back(Point(0, 0, 0));
points.push_back(Point(1, 0, 0));
points.push_back(Point(0, 1, 0));
points.push_back(Point(1, 1, 0));
points.push_back(Point(0, 0, 1));
points.push_back(Point(1, 0, 1));
points.push_back(Point(0, 1, 1));
points.push_back(Point(1, 1, 1));
points.push_back(Point(0.5, 0.5, 0.5));
Triangulation t;
t.insert(points.begin(), points.end());
int i = 1;
for (auto iter = t.finite_vertices_begin(); iter !=
t.finite_vertices_end();
{
stc::cout << "v " << *iter << std::endl;
iter->info() = i;
i++;
}
for (auto iter = t.finite_facets_begin(); iter != t.finite_facets_end();
++it
{
std::cout << "f " << iter->first->vertex((iter->second + 1) % 4)->info()
<< " "
<< iter->first->vertex((iter->second + 2) % 4)->info() << "
"
<< iter->first->vertex((iter->second + 3) % 4)->info() <<
std::
}
return 0;
}
-----------------------------
So, my expectation was that it would make a manifold shape that's roughly a
cube, but would dent in on one side to hit the middle point - or (next best
option) just ignore it altogether. Neither happened. It gave me a profoundly
non-manifold shape. Each vertex has a 7 facets - except for the middle which
has a whopping 18 facets.
------------------------
v 0 0 0
v 0 0 1
v 0 1 1
v 0 1 0
v 1 1 0
v 1 1 1
v 1 0 1
v 0.5 0.5 0.5
v 1 0 0
f 4 2 3
f 4 1 2
f 5 9 7
f 3 2 7
f 2 7 8
f 7 8 3
f 8 3 2
f 3 5 4
f 3 8 6
f 8 6 7
f 6 7 3
f 6 3 5
f 3 8 5
f 8 5 4
f 4 3 8
f 5 4 9
f 7 9 2
f 7 6 5
f 9 1 2
f 9 4 1
f 5 6 8
f 7 8 5
f 2 8 4
f 2 1 8
f 1 8 4
f 8 9 5
f 4 8 9
f 8 7 9
f 8 2 9
f 1 9 8
----------------------------
This is of course unusable to me - it only gets worse when I have larger,
more complex point clouds. I need something that provides a manifold shape
and includes most or ideally all of the points. It can be done in 2d or 3d.
3d would be ideal but 2d (with 3d points) is probably manageable.
I know CGAL has a lot of different triangulation methods but for the life of
me I can't get a one of them to work. Very few of the examples include info
and the manual is as long as War and Peace and as transparent as a brick
wall (sorry... but I've seen lots of responses on this forum that amount to
just "it's easy, just read the manual", so I'm preemptively adding, "already
tried that, it didn't go well"). The learning curve for CGAL seems to be
rather steep. :( Can't tell you how long it took me just to figure out how
to associate indices with vertices in a manner that worked.
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Unexpected-behavior-where-I-can-get-anything-to-work-at-all-tp4660252.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Unexpected behavior, where I can get anything to work at all., Nafnlaus, 12/22/2014
- Re: [cgal-discuss] Unexpected behavior, where I can get anything to work at all., Sebastien Loriot (GeometryFactory), 12/22/2014
Archive powered by MHonArc 2.6.18.