Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Extracting Information to Simple Array Format, Triangulation connectivity

Subject: CGAL users discussion list

List archive

[cgal-discuss] Extracting Information to Simple Array Format, Triangulation connectivity


Chronological Thread 
  • From: htg20 <>
  • To:
  • Subject: [cgal-discuss] Extracting Information to Simple Array Format, Triangulation connectivity
  • Date: Thu, 29 Jul 2010 09:27:40 -0700 (PDT)


#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();


Vertex_iterator begin = T.vertices_begin();
j=0;
for ( ; begin != T.vertices_end(); ++begin){
std::cout << "(" << begin->point() << ")\n ";
//std::cout << "(" << *begin << ")\n ";
if (j>0){
xnodes[j][1]= begin->point().x();
xnodes[j][2]= begin->point().y();
xnodes[j][3]= begin->point().z();
j++;
}
}


Vertex_handle vh1,vh2,vh3,vh4;
Cell_handle ch1;
Cell_iterator beginc = T.cells_begin();
j=0;
for ( ; beginc != T.cells_end(); ++beginc){

//vh1 = beginc -> vertex(2);
//begin=T.vertex->vh1;
//cells[j][1]=beginc->index(vh1);
std::cout << "(" << *beginc << ")\n ";
j++;
}

for ( int j = 0; j < nver; j++ ) {


////printf("%20.10f%20.10f%20.10f\n",xnodes[j][0],xnodes[j][1],xnodes[j][2]);
}

//for ( int j = 0; j < ncell; j++ ) {


////printf("%20.10f%20.10f%20.10f\n",xnodes[j][0],xnodes[j][1],xnodes[j][2]);
//}

std::ofstream oFileT("output",std::ios::out);
// writing file output;
oFileT << T;



return;

}

--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Extracting-Information-to-Simple-Array-Format-Triangulation-connectivity-tp2306742p2306742.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.16.

Top of Page