Thread Previous • Date Previous • Date Next • Thread Next |
On Tue, Oct 31, 2006 at 08:15:33AM +0100, Dag Lindbo wrote: > Hi, > > I'd like to know how the new mesh library handles moving verices in a > mesh. This seems to not work: > > // STRETCH MESH [0 1]x[0 1] -> [a b]x[a b] --------------------%%% > void Mesh_fcns::meshTransformation(Mesh& mesh, real a, real b) > { > for(VertexIterator n(mesh); !n.end(); ++n) > { > Vertex& vertex = *n; > vertex.point().x() = (b-a)*vertex.point().x() + a; > vertex.point().y() = (b-a)*vertex.point().y() + a; > } > } > > How to do it? > /Dag The point() function always returns a copy, so you need to use the coordinates() function which also does not assume that you are in R^3 like point() does: for(VertexIterator v(mesh); !v.end(); ++v) { real* x = v->coordinates(); x[0] = (b-a)*x[0] + a; x[1] = (b-a)*x[1] + a; } This should work. /Anders
Thread Previous • Date Previous • Date Next • Thread Next |