Hello, what is an elegant way to get coordinates of a mesh vertex by its id? For the time being, I've implemented it like this:
typedef viennagrid::triangular_2d_mesh MeshType; typedef viennagrid::result_of::vertex<MeshType>::type VertexType; typedef viennagrid::result_of::point<MeshType>::type PointType; typedef viennagrid::result_of::id<VertexType>::type VertexIDType; unsigned int cell_point_ID = 5; PointType p = viennagrid::find(mesh, VertexIDType(cell_point_ID))[0].appendix();
which looks awkward. Maybe I should use something else (vertex handle for a example) to get coordinates of a mesh vertex in a simple way, shoudn't I?
Thanks, Cyril
Hi Cyril,
if you only have the vertex ID, but nothing else, then viennagrid::find() is all that is left. The reason is that vertex IDs do not have to be contiguous, so a direct array access is not always possible.
viennagrid::find()
You last code line can be simplified to
PointType p = viennagrid::default_point_accessor(*viennagrid::find(mesh, VertexIDType(cell_point_ID));
Best regards, Karli
Hello, Karli. Thanks for the answer, it seems this is what I was looking for.
Best regards, Cyril
Actually, code
doesn't work.
It should be
PointType p = viennagrid::default_point_accessor(mesh)(*viennagrid::find(mesh, VertexIDType(cell_point_ID)));
Log in to post a comment.
Hello, what is an elegant way to get coordinates of a mesh vertex by its id? For the time being, I've implemented it like this:
which looks awkward. Maybe I should use something else (vertex handle for a example) to get coordinates of a mesh vertex in a simple way, shoudn't I?
Thanks,
Cyril
Hi Cyril,
if you only have the vertex ID, but nothing else, then
viennagrid::find()
is all that is left. The reason is that vertex IDs do not have to be contiguous, so a direct array access is not always possible.You last code line can be simplified to
Best regards,
Karli
Hello, Karli. Thanks for the answer, it seems this is what I was looking for.
Best regards,
Cyril
Actually, code
doesn't work.
It should be