diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp index 56941c40e5cf56ee26a66a094607a6e1df2d0542..8ee4fad3700d258a4f8f0050fee241e587698c6e 100644 --- a/Fltk/menuWindow.cpp +++ b/Fltk/menuWindow.cpp @@ -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 } , {""} diff --git a/Geo/GModelIO_Geo.cpp b/Geo/GModelIO_Geo.cpp index e033b65a444369f5adaf32702b54c35d9c62afdc..fa86f83f936dc9fd2eeee9a20d678cb7c624d6e8 100644 --- a/Geo/GModelIO_Geo.cpp +++ b/Geo/GModelIO_Geo.cpp @@ -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++){ @@ -185,15 +184,17 @@ int GModel::importGEOInternals() for(int i = 0; i < List_Nbr(_geo_internals->PhysicalGroups); i++){ PhysicalGroup *p; List_Read(_geo_internals->PhysicalGroups, i, &p); - std::vector<GEdge*>e_compound; - std::list<GFace*>f_compound; - std::vector<GRegion*>r_compound; + std::vector<GEdge*> e_compound; + std::list<GFace*> f_compound; + std::vector<GRegion*> r_compound; for(int j = 0; j < List_Nbr(p->Entities); j++){ int num; 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){ diff --git a/Geo/GeoStringInterface.cpp b/Geo/GeoStringInterface.cpp index 62d9ce497250b63355c06b5b33eec13efaf4247a..141f2584ca70689935097eccb6d6c3f2ff56ebd6 100644 --- a/Geo/GeoStringInterface.cpp +++ b/Geo/GeoStringInterface.cpp @@ -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; diff --git a/Geo/GeoStringInterface.h b/Geo/GeoStringInterface.h index 8ea3e784895903df5d84a794ed2944640aedf96d..9a161e3ad77a692af5177f0275a2857862b53778 100644 --- a/Geo/GeoStringInterface.h +++ b/Geo/GeoStringInterface.h @@ -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);