Export 3d delaunay triangulation

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Export 3d delaunay triangulation

mozendi
Dear CGAL users,
I am a new CGAL user. My objective is to create 3d delaunay triangulation from terrestrial LIDAR points clouds. So that, each point of the cloud will be set as a vertex.
After some efforts on CGAL I came up with the code below:

// types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned, Kernel> Vb;
typedef CGAL::Triangulation_data_structure_3<Vb> Tds;
typedef CGAL::Delaunay_triangulation_3<Kernel, Tds, CGAL::Fast_location> Delaunay;
typedef Delaunay::Point Point;


int main(int argc, char*argv[])
{
        // Reads a .xyz point set file in points[].
        std::vector<Point> points;
        std::vector<Vector> normals;
        const char* fname = (argc>1) ? argv[1] : "data/SIL_ARKA_1cm_POINTS_NORMALS.xyz";
        std::ifstream stream(fname);
        Point p;
        Vector v;
        while (stream >> p >> v) {
                points.push_back(p);
                normals.push_back(v);
        }
       
        std::vector<std::size_t> indices(points.size());
        for (std::size_t i = 0; i < points.size(); ++i) {
                indices[i] = i;
        }
        std::cout << "Point Cloud is Loaded" << std::endl;
        std::cout << points.size() << " input points" << std::endl;
        std::cout << " -------------------------------" << std::endl;
        std::cout << " START BUILDING THE TRIANGULATION" << std::endl;
        Delaunay T(points.begin(), points.end());
        std::cout << " TRIANGULTION COMPLETED" << std::endl;
        std::cout << " -------------------------------" << std::endl;
        std::ofstream oFileT("testFile1", std::ios::out);
        oFileT << T;

        return EXIT_SUCCESS;
}

As a result of this program I get the txt file "testFile1". However, I could not find any description for this file. Is it possible to convert this file to well known file formats such as .ply, .stl or .obj. Moreover, do you think is it the correct way of creating 3D delaunay triangulation from point clouds that are stored in .xyz file?
I am looking forward to hearing from you
Regards


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export 3d delaunay triangulation

teillaud
Administrator
Hi 

You will find a description of the file in paragraph "I/O" of page http://doc.cgal.org/latest/Triangulation_3/classCGAL_1_1Triangulation__3.html

Best,

--
Monique Teillaud 
https://members.loria.fr/Monique.Teillaud/
INRIA Nancy - Grand Est, LORIA 
Institut National de Recherche en Informatique et Automatique 

On 13 May 2017, at 00:25, mozendi <[hidden email]> wrote:

Dear CGAL users,
I am a new CGAL user. My objective is to create 3d delaunay triangulation
from terrestrial LIDAR points clouds. So that, each point of the cloud will
be set as a vertex.
After some efforts on CGAL I came up with the code below:

// types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned, Kernel> Vb;
typedef CGAL::Triangulation_data_structure_3<Vb> Tds;
typedef CGAL::Delaunay_triangulation_3<Kernel, Tds, CGAL::Fast_location>
Delaunay;
typedef Delaunay::Point Point;


int main(int argc, char*argv[])
{
// Reads a .xyz point set file in points[].
std::vector<Point> points;
std::vector<Vector> normals;
const char* fname = (argc>1) ? argv[1] :
"data/SIL_ARKA_1cm_POINTS_NORMALS.xyz";
std::ifstream stream(fname);
Point p;
Vector v;
while (stream >> p >> v) {
points.push_back(p);
normals.push_back(v);
}

std::vector<std::size_t> indices(points.size());
for (std::size_t i = 0; i < points.size(); ++i) {
indices[i] = i;
}
std::cout << "Point Cloud is Loaded" << std::endl;
std::cout << points.size() << " input points" << std::endl;
std::cout << " -------------------------------" << std::endl;
std::cout << " START BUILDING THE TRIANGULATION" << std::endl;
Delaunay T(points.begin(), points.end());
std::cout << " TRIANGULTION COMPLETED" << std::endl;
std::cout << " -------------------------------" << std::endl;
std::ofstream oFileT("testFile1", std::ios::out);
oFileT << T;

return EXIT_SUCCESS;
}

As a result of this program I get the txt file "testFile1". However, I could
not find any description for this file. Is it possible to convert this file
to well known file formats such as .ply, .stl or .obj. Moreover, do you
think is it the correct way of creating 3D delaunay triangulation from point
clouds that are stored in .xyz file?
I am looking forward to hearing from you
Regards






--
View this message in context: http://cgal-discuss.949826.n4.nabble.com/Export-3d-delaunay-triangulation-tp4662725.html
Sent from the cgal-discuss mailing list archive at 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



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export 3d delaunay triangulation

chrism
In reply to this post by mozendi
Hi Mozendi,

I am using CGAL to do something similar as you (build a triangulation of terrain from a set of points) 

I don't think the triangulation_3 is what you want. The 3D triangulation allows for connecting the vertexes in 3-space whereas what I think you want is a 2.5D mesh. That is, your vertexes have elevation, but the triangulation is only connected in 2D.

An example of what I'm doing is found here

If this what you want, the key is to use vertexes that have 3D information (x,y,z), but the triangulation exists on a plane. 

The projection_traits_xy_3 is required as it allows for using the 2D algorithms on the 3D vertexes.

For outputting, I use the VTU format from the VTK library and visualise in VTK. You have to manually build the vtk datastructure from the cgal triangulation though. It is straightforward but non-trivial. 
Otherwise I would just build the STL file yourself.

Hope this helps

Cheers
Chris

On 12 May 2017 at 16:25, mozendi <[hidden email]> wrote:
Dear CGAL users,
I am a new CGAL user. My objective is to create 3d delaunay triangulation
from terrestrial LIDAR points clouds. So that, each point of the cloud will
be set as a vertex.
After some efforts on CGAL I came up with the code below:

// types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned, Kernel> Vb;
typedef CGAL::Triangulation_data_structure_3<Vb> Tds;
typedef CGAL::Delaunay_triangulation_3<Kernel, Tds, CGAL::Fast_location>
Delaunay;
typedef Delaunay::Point Point;


int main(int argc, char*argv[])
{
        // Reads a .xyz point set file in points[].
        std::vector<Point> points;
        std::vector<Vector> normals;
        const char* fname = (argc>1) ? argv[1] :
"data/SIL_ARKA_1cm_POINTS_NORMALS.xyz";
        std::ifstream stream(fname);
        Point p;
        Vector v;
        while (stream >> p >> v) {
                points.push_back(p);
                normals.push_back(v);
        }

        std::vector<std::size_t> indices(points.size());
        for (std::size_t i = 0; i < points.size(); ++i) {
                indices[i] = i;
        }
        std::cout << "Point Cloud is Loaded" << std::endl;
        std::cout << points.size() << " input points" << std::endl;
        std::cout << " -------------------------------" << std::endl;
        std::cout << " START BUILDING THE TRIANGULATION" << std::endl;
        Delaunay T(points.begin(), points.end());
        std::cout << " TRIANGULTION COMPLETED" << std::endl;
        std::cout << " -------------------------------" << std::endl;
        std::ofstream oFileT("testFile1", std::ios::out);
        oFileT << T;

        return EXIT_SUCCESS;
}

As a result of this program I get the txt file "testFile1". However, I could
not find any description for this file. Is it possible to convert this file
to well known file formats such as .ply, .stl or .obj. Moreover, do you
think is it the correct way of creating 3D delaunay triangulation from point
clouds that are stored in .xyz file?
I am looking forward to hearing from you
Regards






--
View this message in context: http://cgal-discuss.949826.n4.nabble.com/Export-3d-delaunay-triangulation-tp4662725.html
Sent from the cgal-discuss mailing list archive at 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



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Export 3d delaunay triangulation

mozendi
Dear Chris,

Thank you for the explanations. Honestly speaking I am confused a little about the 2.5D and 3D case. My dataset is terrestrial laser scanner derived point clouds. Many points may have the same z or elevation value. In this case, do you think 2D triangulation will work? By the way, I can not see the imgur link from my country. Could you please send me another link?
Regards
Mustafa
 
Loading...