Skip to content
Snippets Groups Projects
Commit ef5e8b10 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

gui for embedded points

parent 33b8f132
No related branches found
No related tags found
No related merge requests found
......@@ -1794,7 +1794,7 @@ static void mesh_define_transfinite_cb(Fl_Widget *w, void *data)
FlGui::instance()->menu->setContext(menu_mesh_define_transfinite, 0);
}
static void add_transfinite(int dim)
static void add_transfinite_embedded(int dim, bool embed)
{
opt_geometry_points(0, GMSH_SET | GMSH_GUI, 1);
switch (dim) {
......@@ -1885,17 +1885,22 @@ static void add_transfinite(int dim)
}
while(1) {
if(p.size() == 1)
Msg::StatusBar(3, false, "Select (ordered) boundary points\n"
"[Press 'e' to end selection or 'q' to abort]");
Msg::StatusBar(3, false, "Select %s points\n"
"[Press 'e' to end selection or 'q' to abort]",
embed ? "embedded" : "(ordered) boundary");
else
Msg::StatusBar(3, false, "Select (ordered) boundary points\n"
Msg::StatusBar(3, false, "Select %s points\n"
"[Press 'e' to end selection, 'u' to undo last selection "
"or 'q' to abort]");
"or 'q' to abort]",
embed ? "embedded" : "(ordered) boundary");
ib = FlGui::instance()->selectEntity(ENT_POINT);
if(ib == 'l') {
FlGui::instance()->selectedVertices[0]->setSelection(1);
for(unsigned int i = 0; i < FlGui::instance()->selectedVertices.size(); i++){
FlGui::instance()->selectedVertices[i]->setSelection(1);
p.push_back(FlGui::instance()->selectedVertices[i]->tag());
if(!embed) break;
}
drawContext::global()->draw();
p.push_back(FlGui::instance()->selectedVertices[0]->tag());
}
if(ib == 'u') {
if(p.size() > 1){
......@@ -1912,11 +1917,14 @@ static void add_transfinite(int dim)
if(ib == 'e') {
switch (dim) {
case 2:
if(p.size() == 0 + 1 || p.size() == 3 + 1 || p.size() == 4 + 1)
if(embed && p.size())
add_embedded("Point", p, GModel::current()->getFileName());
else if(!embed &&
(p.size() == 0 + 1 || p.size() == 3 + 1 || p.size() == 4 + 1))
add_trsfsurf(p, GModel::current()->getFileName(),
FlGui::instance()->meshContext->choice[1]->text());
else
Msg::Error("Wrong number of points for transfinite surface");
Msg::Error("Wrong number of points for mesh constraint");
break;
case 3:
if(p.size() == 6 + 1 || p.size() == 8 + 1)
......@@ -1948,18 +1956,23 @@ static void add_transfinite(int dim)
static void mesh_define_transfinite_line_cb(Fl_Widget *w, void *data)
{
FlGui::instance()->meshContext->show(1);
add_transfinite(1);
add_transfinite_embedded(1, false);
}
static void mesh_define_transfinite_surface_cb(Fl_Widget *w, void *data)
{
FlGui::instance()->meshContext->show(2);
add_transfinite(2);
add_transfinite_embedded(2, false);
}
static void mesh_define_transfinite_volume_cb(Fl_Widget *w, void *data)
{
add_transfinite(3);
add_transfinite_embedded(3, false);
}
static void mesh_define_embedded_cb(Fl_Widget *w, void *data)
{
add_transfinite_embedded(2, true);
}
static void view_toggle_cb(Fl_Widget *w, void *data)
......@@ -2498,6 +2511,7 @@ contextItem menu_mesh[] = {
{"1Mesh>Define"} ,
{"Fields", (Fl_Callback *)field_cb},
{"Characteristic length", (Fl_Callback *)mesh_define_length_cb } ,
{"Embedded point", (Fl_Callback *)mesh_define_embedded_cb, (void*)"point" } ,
{"Recombine", (Fl_Callback *)mesh_define_recombine_cb } ,
{"Transfinite", (Fl_Callback *)mesh_define_transfinite_cb } ,
{""}
......
......@@ -43,17 +43,18 @@ int GModel::readGEO(const std::string &name)
int GModel::exportDiscreteGEOInternals()
{
_geo_internals = new GEO_Internals;
for(viter it = firstVertex(); it != lastVertex(); it++){
Vertex *v = Create_Vertex((*it)->tag(), (*it)->x(), (*it)->y(), (*it)->z(), (*it)->prescribedMeshSizeAtVertex(), 1.0);
Vertex *v = Create_Vertex((*it)->tag(), (*it)->x(), (*it)->y(), (*it)->z(),
(*it)->prescribedMeshSizeAtVertex(), 1.0);
Tree_Add(GModel::current()->getGEOInternals()->Points, &v);
}
for(eiter it = firstEdge(); it != lastEdge(); it++){
if((*it)->geomType() == GEntity::DiscreteCurve){
Curve *c = Create_Curve((*it)->tag(), MSH_SEGM_DISCRETE, 1, NULL, NULL, -1, -1, 0., 1.);
Curve *c = Create_Curve((*it)->tag(), MSH_SEGM_DISCRETE, 1,
NULL, NULL, -1, -1, 0., 1.);
List_T *points = Tree2List(_geo_internals->Points);
GVertex *gvb = (*it)->getBeginVertex();
GVertex *gve = (*it)->getEndVertex();
......@@ -95,8 +96,7 @@ int GModel::exportDiscreteGEOInternals()
}
}
//create Volumes from discreteRegions
//TODO
// TODO: create Volumes from discreteRegions
Msg::Debug("Geo internal model has:");
List_T *points = Tree2List(_geo_internals->Points);
......@@ -111,7 +111,6 @@ int GModel::exportDiscreteGEOInternals()
int GModel::importGEOInternals()
{
if(Tree_Nbr(_geo_internals->Points)) {
List_T *points = Tree2List(_geo_internals->Points);
for(int i = 0; i < List_Nbr(points); i++){
......@@ -193,7 +192,9 @@ int GModel::importGEOInternals()
List_Read(p->Entities, j, &num);
GEntity *ge = 0;
switch(p->Typ){
case MSH_PHYSICAL_POINT: ge = getVertexByTag(abs(num)); break;
case MSH_PHYSICAL_POINT:
ge = getVertexByTag(abs(num));
break;
case MSH_PHYSICAL_LINE:
ge = getEdgeByTag(abs(num));
e_compound.push_back(getEdgeByTag(abs(num)));
......@@ -213,11 +214,9 @@ int GModel::importGEOInternals()
ge->physicals.push_back(pnum);
}
// the physical is a compound i.e. we allow the meshes
// not to conform internal MEdges of the compound
if (p->Typ == MSH_PHYSICAL_LINE && p->Boundaries[0]){
GEdge *ge = getEdgeByTag(abs(p->Num));
if (!ge){
......
......@@ -20,7 +20,7 @@
#include "Parser.h"
#endif
void add_infile(std::string text, std::string fileName, bool deleted_something)
void add_infile(std::string text, std::string fileName, bool forceDestroy)
{
// make sure we don't add stuff in a non-geo file
if(!CTX::instance()->expertMode) {
......@@ -80,9 +80,9 @@ void add_infile(std::string text, std::string fileName, bool deleted_something)
fclose(gmsh_yyin);
gmsh_yyin = gmsh_yyin_old;
if(deleted_something){
// we need to start from scratch since the command just parsed
// could have deleted some entities
if(forceDestroy){
// we need to start from scratch (e.g. if the command just parsed
// could have deleted some entities)
GModel::current()->destroy();
}
GModel::current()->importGEOInternals();
......@@ -183,6 +183,18 @@ void add_trsfvol(std::vector<int> &l, std::string fileName)
add_infile(sstream.str(), fileName);
}
void add_embedded(std::string what, std::vector<int> &l, std::string fileName)
{
std::ostringstream sstream;
sstream << "Point{";
for(unsigned int i = 1; i < l.size(); i++) {
if(i > 1) sstream << ", ";
sstream << l[i];
}
sstream << "} In Surface{" << l[0] << "};";
add_infile(sstream.str(), fileName, true);
}
void add_param(std::string par, std::string value, std::string fileName)
{
std::ostringstream sstream;
......
......@@ -19,6 +19,7 @@ void add_trsfline(std::vector<int> &l, std::string fileName, std::string type,
std::string typearg, std::string pts);
void add_trsfsurf(std::vector<int> &l, std::string fileName, std::string dir);
void add_trsfvol(std::vector<int> &l, std::string fileName);
void add_embedded(std::string what, std::vector<int> &l, std::string fileName);
void add_param(std::string par, std::string value, std::string fileName);
void add_point(std::string fileName, std::string x, std::string y, std::string z,
std::string lc);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment