Subject: CGAL users discussion list
List archive
Re: [cgal-discuss] Extracting Information to Simple Array Format, Triangulation connectivity
Chronological Thread
- From: Monique Teillaud <>
- To:
- Subject: Re: [cgal-discuss] Extracting Information to Simple Array Format, Triangulation connectivity
- Date: Thu, 29 Jul 2010 18:41:59 +0200
Hi,
I guess that you can get some inspiration from the code of the I/O functionality of the class Triangulation_data_structure_3 (and Triangulation_3 for the additional geometric information).
Best regards,
Monique Teillaud
htg20 wrote:
Hello!
I have just started to use CGAL to connect it to my Finite Element code. My
FEM code is in Fortran and I have made a C++ interface. From the Fortran
code, I send a (n*3) array of points and I want to Triangulate and send the
triangulation connectivities back to the Fortran code. But I could not get
the connectivity array back; I am searching for the quickest way to exchange
data. Could you please provide me with a sample code? Many thanks.
I have something like:
#include <iostream>
#include <fstream>
#include <iterator>
#include <unistd.h>
#include <CGAL/basic.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_3<K> Triangulation;
typedef Triangulation::Cell_handle Cell_handle;
typedef Triangulation::Vertex_handle Vertex_handle;
typedef Triangulation::Locate_type Locate_type;
typedef Triangulation::Point Point;
typedef Triangulation::Vertex_iterator Vertex_iterator;
typedef Triangulation::Cell_iterator Cell_iterator;
extern "C"
{
/* in--nver: number of vertices
in--xnodes: all the vertices to be triangulated
out--ncell: number of triangulations
out-- cells: triangles
*/
void cpptest ( double xnodes[][3], int nver,int ncell, int
cells[][4]);
}
extern void cpptest( double xnodes[][3],int nver, int ncell, int cells[][4]
)
{
int i,j;
// insertion from a vector :
std::vector<Point> V(nver);
for ( int j = 0; j < nver; j++ ) {
V[j] = Point(xnodes[j][0],xnodes[j][1],xnodes[j][2]);
//printf("%20.10f%20.10f%20.10f\n",xnodes[j][0],xnodes[j][1],xnodes[j][2]);
}
Triangulation T(V.begin(), V.end());
//validation check
assert( T.is_valid() );
//write the vertices and the cells back to the Caller(Fortran)
nver = T.number_of_vertices();
ncell=T.number_of_cells();
// how to get the connectivity for the array cells[ncell][4]
return;
}
--
Monique Teillaud
INRIA Sophia Antipolis - Méditerranée
http://www.inria.fr/sophia/members/Monique.Teillaud/
- [cgal-discuss] Extracting Information to Simple Array Format, Triangulation connectivity, htg20, 07/29/2010
- <Possible follow-up(s)>
- [cgal-discuss] Extracting Information to Simple Array Format, Triangulation connectivity, htg20, 07/29/2010
- Re: [cgal-discuss] Extracting Information to Simple Array Format, Triangulation connectivity, Monique Teillaud, 07/29/2010
Archive powered by MHonArc 2.6.16.