[Gmsh] Implementing loop direction in C++
Tolga Kurt
kurt.tolga at gmail.com
Mon Jun 11 10:36:22 CEST 2012
In some other thread, it has been showed that the equivalent of a GEO
script in C++ is something as follows.
// Add lines. Equivalent .geo directives are
// Line(1) = {1, 2};
// Line(2) = {2, 3};
// Line(3) = {3, 4};
// Line(4) = {4, 1};
GEdge *ge1 = m->addLine(gv1, gv2);
GEdge *ge2 = m->addLine(gv2, gv3);
GEdge *ge3 = m->addLine(gv3, gv4);
GEdge *ge4 = m->addLine(gv4, gv1);
// Add line loop. Equivalent .geo directive is
// Line Loop(1) = {1, 2, 3, 4};
std::vector<std::vector<GEdge *> > lineLoop1(1);
lineLoop1[0].push_back(ge1);
My question is, how can I set a sign for a line's orientation in the
loop. In other words I need to convert
Line Loop(1) = {1, -2, 3, -4}
to c++ code. Explicitly saying, I have 4 points that are corners of a
tetrahedron and I have added the lines
GEdge* gedge[6];
gedge[0] = m->addLine(gv[0], gv[1]);
gedge[1] = m->addLine(gv[1], gv[2]);
gedge[2] = m->addLine(gv[2], gv[0]);
gedge[3] = m->addLine(gv[0], gv[3]);
gedge[4] = m->addLine(gv[1], gv[3]);
gedge[5] = m->addLine(gv[2], gv[3]);
So that, when I add the first surface as (Line Loop(1) = {1,2,3})
vector<GEdge*> ge[4];
ge[0].push_back(gedge[0]);
ge[0].push_back(gedge[1]);
ge[0].push_back(gedge[2]);
there is no problem.
But when it comes to add the second surface with these existing lines, I
need to add the loop (Line Loop(2) = {1, 5, -4} )
Otherwise, it says that the loop is wrong (when I just add the line 4
without a sign)
Any help would be great.
Thanks in advance,
Tolga Kurt.