Subject: CGAL users discussion list
List archive
- From: "Veronica E. Arriola" <>
- To:
- Subject: Re: [cgal-discuss] acquire mesh information
- Date: Fri, 28 Jan 2011 14:08:33 +0000
- Organization: School of Computer Science, University of Birmingham
Hi,
It seem that what you want are the Iterators and Circulators. With them
you can do things like:
#include <opencv/highgui.h>
#include ... // CGAL stuff
...
typedef Triangulation::Vertex_circulator VertexCirculator;
typedef Triangulation::Edge_circulator EdgeCirculator;
typedef Triangulation::Face_circulator FaceCirculator;
typedef Triangulation::Finite_vertices_iterator VerticesIterator;
typedef Triangulation::Finite_edges_iterator EdgesIterator;
typedef Triangulation::Finite_faces_iterator FacesIterator;
typedef Triangulation::Face Face;
typedef Triangulation::Edge Edge;
typedef Triangulation::Point Point;
typedef Triangulation::Vertex Vertex;
typedef Triangulation::Vertex_handle Vertex_handle;
typedef Triangulation::Face_handle Face_handle;
...
void drawOriginalMesh(IplImage *img, Triangulation &t){
Point p1, p2;
for(EdgesIterator ei = t.finite_edges_begin(),
end = t.finite_edges_end();
ei != end; ++ei){
p1 = ei->first->vertex(t.cw(ei->second))->point();
p2 = ei->first->vertex(t.ccw(ei->second))->point();
cvLine(img, cvPoint((int)(p1.x()), (int)(p1.y())),
cvPoint((int)(p2.x()),
(int)(p2.y())), CV_RGB(200,200,200));
}
for(VerticesIterator vi = t.finite_vertices_begin(),
end = t.finite_vertices_end();
vi != end; ++vi){
cvCircle(img, cvPoint(vi->point().x(), vi->point().y()), 1.0,
CV_RGB(200, 200, 200));
}
for(FacesIterator fi = t.finite_faces_begin(),
end = t.finite_faces_end();
fi != end; ++fi){
int x = (int)(0.5 * (0.5 *
(fi->vertex(1)->point().x() +
fi->vertex(2)->point().x()) + fi->vertex(0)->point().x()));
int y = (int)(0.5 * (0.5 *
(fi->vertex(1)->point().y() +
fi->vertex(2)->point().y()) + fi->vertex(0)->point().y()));
cvCircle(img, cvPoint(x, y), 2.0, CV_RGB(250, 0, 0));
}
}
On 27/01/11 21:19, ppmm wrote:
>
> Hello,
>
> I am new to CGAL. I would like to use CGAL to create the 2D meshes for FEM
> analysis.
>
> My question is how to get the mesh information from the generated mesh, such
> as point coordinate and each zone is defined by which three points.
>
> For example, how to get those information from the mesh_class.cpp example
> listed below.
>
> Thanks a lot for your help.
>
>
>
>
> #include <CGAL/Delaunay_mesh_size_criteria_2.h>
>
> #include <iostream>
>
> typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
> typedef CGAL::Triangulation_vertex_base_2<K> Vb;
> typedef CGAL::Delaunay_mesh_face_base_2<K> Fb;
> typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
> typedef CGAL::Constrained_Delaunay_triangulation_2<K, Tds> CDT;
> typedef CGAL::Delaunay_mesh_size_criteria_2<CDT> Criteria;
> typedef CGAL::Delaunay_mesher_2<CDT, Criteria> Mesher;
>
> typedef CDT::Vertex_handle Vertex_handle;
> typedef CDT::Point Point;
>
> int main()
> {
> CDT cdt;
>
> Vertex_handle va = cdt.insert(Point(-4,0));
> Vertex_handle vb = cdt.insert(Point(0,-1));
> Vertex_handle vc = cdt.insert(Point(4,0));
> Vertex_handle vd = cdt.insert(Point(0,1));
> cdt.insert(Point(2, 0.6));
>
> cdt.insert_constraint(va, vb);
> cdt.insert_constraint(vb, vc);
> cdt.insert_constraint(vc, vd);
> cdt.insert_constraint(vd, va);
>
> std::cout << "Number of vertices: " << cdt.number_of_vertices() <<
> std::endl;
>
> std::cout << "Meshing the triangulation with default criterias..."
> << std::endl;
>
> Mesher mesher(cdt);
> mesher.refine_mesh();
>
> std::cout << "Number of vertices: " << cdt.number_of_vertices() <<
> std::endl;
>
> std::cout << "Meshing with new criterias..." << std::endl;
> // 0.125 is the default shape bound. It corresponds to abound 20.6 degree.
> // 0.5 is the upper bound on the length of the longuest edge.
> // See reference manual for Delaunay_mesh_size_traits_2<K>.
> mesher.set_criteria(Criteria(0.125, 0.5));
> mesher.refine_mesh();
>
> std::cout << "Number of vertices: " << cdt.number_of_vertices() <<
> std::endl;
> }
>
--
Veronica E. Arriola
Office 144
School of Computer Science
University of Birmingham
http://www.cs.bham.ac.uk/~vxa855/
- [cgal-discuss] acquire mesh information, ppmm, 01/27/2011
- Re: [cgal-discuss] acquire mesh information, Sebastien Loriot (GeometryFactory), 01/28/2011
- Re: [cgal-discuss] acquire mesh information, Veronica E. Arriola, 01/28/2011
Archive powered by MHonArc 2.6.16.