From 90bae6d5f95f141aecf35df71eb83e6949513742 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 27 Sep 2013 07:05:25 +0000 Subject: [PATCH] add simple example for creating a geometry using the factory --- utils/api_demos/CMakeLists.txt | 3 +++ utils/api_demos/mainElasticity.cpp | 2 +- utils/api_demos/mainGeoFactory.cpp | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 utils/api_demos/mainGeoFactory.cpp diff --git a/utils/api_demos/CMakeLists.txt b/utils/api_demos/CMakeLists.txt index b10031326e..8fc105af2f 100644 --- a/utils/api_demos/CMakeLists.txt +++ b/utils/api_demos/CMakeLists.txt @@ -53,3 +53,6 @@ target_link_libraries(mainPost shared) add_executable(mainSimple mainSimple.cpp) target_link_libraries(mainSimple shared) +add_executable(mainGeoFactory mainGeoFactory.cpp) +target_link_libraries(mainGeoFactory shared) + diff --git a/utils/api_demos/mainElasticity.cpp b/utils/api_demos/mainElasticity.cpp index 68236fcddd..b056d0ac6b 100644 --- a/utils/api_demos/mainElasticity.cpp +++ b/utils/api_demos/mainElasticity.cpp @@ -28,7 +28,7 @@ void InitializeOnelab(std::string sockName, std::string modelName) { ps[0].setValue(modelName); loader->set(ps[0]); } -/* + void AddOnelabNumberChoice(std::string name, double val, std::string help) { std::vector<double> choices; diff --git a/utils/api_demos/mainGeoFactory.cpp b/utils/api_demos/mainGeoFactory.cpp new file mode 100644 index 0000000000..fe518ed251 --- /dev/null +++ b/utils/api_demos/mainGeoFactory.cpp @@ -0,0 +1,29 @@ +#include <stdio.h> +#include "Gmsh.h" +#include "GModel.h" + +int main(int argc, char **argv) +{ + GmshInitialize(argc, argv); + GModel *m = new GModel(); + + GVertex *v1 = m->addVertex(0, 0, 0, 0.1); + GVertex *v2 = m->addVertex(1, 0, 0, 0.1); + GVertex *v3 = m->addVertex(1, 1, 0, 0.1); + GVertex *v4 = m->addVertex(0, 1, 0, 0.1); + + std::vector<GEdge*> edges; + edges.push_back(m->addLine(v1, v2)); + edges.push_back(m->addLine(v2, v3)); + edges.push_back(m->addLine(v3, v4)); + edges.push_back(m->addLine(v4, v1)); + + std::vector<std::vector<GEdge*> > loop; + loop.push_back(edges); + GFace *f = m->addPlanarFace(loop); + + m->mesh(2); + m->writeMSH("test.msh"); + delete m; + GmshFinalize(); +} -- GitLab