Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] hot to get Vertex index from Cells_in_complex_iterator

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] hot to get Vertex index from Cells_in_complex_iterator


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] hot to get Vertex index from Cells_in_complex_iterator
  • Date: Fri, 07 Nov 2014 10:01:11 +0100
  • Organization: GeometryFactory

On 10/27/2014 09:51 AM, hiroki shibata wrote:
first, i am japanease. i am sorry my poor english.

I want to generate FEM mesh by using CGAL. And I want vertices and cell have
vertex index.
following is my code.

#include "targetver.h"
#include <map>
#include <stdio.h>
#include <tchar.h>
#include <CGAL\Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL\Mesh_triangulation_3.h>
#include <CGAL\Mesh_complex_3_in_triangulation_3.h>
#include <CGAL\Mesh_criteria_3.h>
#include <CGAL\make_mesh_3.h>
#include <CGAL\Implicit_mesh_domain_3.h>

// Domain
typedef CGAL::Exact_predicates_inexact_constructions_kernel kernel;


typedef kernel::FT FT;
typedef kernel::Point_3 Point;
typedef FT (Function)(const Point&);
typedef CGAL::Implicit_mesh_domain_3<Function,kernel> Mesh_domain;

// Triangulation
typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3
C3t3;
// Criteria
typedef CGAL::Mesh_criteria_3
Mesh_criteria;



// To avoid verbose function and named parameters call
using namespace std;
using namespace CGAL::parameters;
// Function

FT sphere_function (const Point& p){
return CGAL::squared_distance(p, Point(CGAL::ORIGIN))-1;
}
int main()
{
// Domain(Warning: Sphere_3 constructor uses squared radius !)
Mesh_domain domain(sphere_function, kernel::Sphere_3(CGAL::ORIGIN,
2.));
// Mesh criteria
Mesh_criteria criteria(facet_angle=30, facet_size=0.1,
facet_distance=0.025,
cell_radius_edge_ratio=2, cell_size=0.1);
// Mesh generation
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);
// Output
std::ofstream medit_file("out.mesh");
c3t3.output_to_medit(medit_file);

Tr tr = c3t3.triangulation();

int i=0;
std::map<Tr::Vertex_handle , int> Va;
for(Tr::Finite_vertices_iterator
it=tr.finite_vertices_begin();it!=tr.finite_vertices_end();it++)
{
Va[it] = i;
i++;
}
for(C3t3::Cells_in_complex_iterator
it=c3t3.cells_in_complex_begin();it !=
c3t3.cells_in_complex_end();it++)
{
i = Va[it->vertex(0)];
*//i is always 0*
}
return 0;
}


why can not i get the mapped value from "Va" using
"Cell_in_complex_iterator::vertex(0)" ?.
"Va" always return "0".
please help me.


Tr tr = c3t3.triangulation();

is making a copy of the triangulation.

try:
const Tr& tr = c3t3.triangulation();

Sebastien.





--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/hot-to-get-Vertex-index-from-Cells-in-complex-iterator-tp4660013.html
Sent from the cgal-discuss mailing list archive at Nabble.com.




  • Re: [cgal-discuss] hot to get Vertex index from Cells_in_complex_iterator, Sebastien Loriot (GeometryFactory), 11/07/2014

Archive powered by MHonArc 2.6.18.

Top of Page