[Gmsh] Change coordinate of a vertex in a GModel using API

Mikhail Artemyev artemiev.mikhail at gmail.com
Tue May 27 17:31:59 CEST 2014

All right.

Then use these functions to get non-const iterators pointing to vertices:

// from GModel class
typedef std::set<GVertex*, GEntityLessThan>::iterator viter;
viter firstVertex() { return vertices.begin(); }
viter lastVertex() { return vertices.end(); }

or, I guess you can redefine getVertexByTag function in such a way that 
it wouldn't be const and give you a non-const vertex iterator (in this 
case you'll clearly need to recompile the Gmsh library).

Best regards,

On 05/27/2014 10:14 AM, Agnese, Marco wrote:
> Hi Mikhail,
> the problem of adding and deleting a vertex is that I have to redefine also the topology (I think, am I right ?).
> For example let's say that my GModel defining a rectangle: 4 vertices (from 1 to 4), 4 edges (from 1 to 4), 1 lines loops, 1 plane surface.
> Let's say that I want now move thew first vertex and keep everything the same (and obtain a quadrilateral). If I delete the first vertex, the two edges which contain the vertex number 1 need to be deleted and recreated with the new vertex which I want to add.
> In case the geometry is more complicated, maybe I have also to create again the lines loops.
> This procedure is quite inefficient and could become complicated (especially in 3D).
> If I can delete a vertex and add with the new coordinates without recreating my edges this could be a good solution to my problem. For know I recreate from scratch the GModel with the right coordinates, but of course this requires a certain amount of code and more operations to be performed by the code.
> Chhers, Marco.
> ________________________________________
> From: Mikhail Artemyev [artemiev.mikhail at gmail.com]
> Sent: Tuesday, May 27, 2014 3:51 PM
> To: gmsh at geuz.org; Agnese, Marco
> Subject: Re: Change coordinate of a vertex in a GModel using API
> Hi Marco,
> I would suggest to remove a wrong vertex from a model using:
> void remove(GVertex *v); // from GModel class
> and then to add a new (corrected) one:
> void add(GVertex *v) { vertices.insert(v); } // from GModel class
> However I didn't try that for myself.
> Best regards,
> Mikhail
>> Hello GMSH users,
>> I have a GModel and I want to change the coordinates of a point inside it: just the coordinates of a point , everything in the GModel need to remains exactly the same.
>> Is there a way without creating from scratch a new GModel?
>> Because if I extract the pointer to a GVertex with the method getVertexByTag I have a const pointer therefore I cannot modify the value but only read it.
>> Is there a method to have a non const pointer? Or is there  a method to simply change the coordinates?
>> Thank you,
>> cheers,
>> Marco Agnese.