From 2cc929e0306a3b4aa38f1fb7f72469eaa699fab8 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 18 Nov 2017 07:49:20 +0100 Subject: [PATCH] removed gmshModelGetVertexCoordinates (not necessary) + return parametric coords in gmshModelGetMeshVertices --- Common/gmsh.cpp | 29 ++++++++++------------------- Common/gmsh.h | 5 ++--- demos/api/explore.cpp | 4 ++-- demos/api/explore.py | 6 +++--- demos/api/open.py | 2 +- demos/api/t1.cpp | 9 +++++---- demos/api/t1.py | 8 +++++--- demos/api/t2.cpp | 3 ++- 8 files changed, 30 insertions(+), 36 deletions(-) diff --git a/Common/gmsh.cpp b/Common/gmsh.cpp index 5e197788cc..55770ef6c9 100644 --- a/Common/gmsh.cpp +++ b/Common/gmsh.cpp @@ -278,20 +278,6 @@ GMSH_API gmshModelGetPhysicalName(const int dim, const int tag, return GMSH_OK; } -GMSH_API gmshModelGetVertexCoordinates(const int tag, double &x, double &y, - double &z) -{ - if(!_isInitialized()) return GMSH_ERROR(-1); - GVertex *gv = GModel::current()->getVertexByTag(tag); - if(gv){ - x = gv->x(); - y = gv->y(); - z = gv->z(); - return GMSH_OK; - } - return GMSH_ERROR(1); -} - GMSH_API gmshModelGetBoundary(const vector_pair &inDimTags, vector_pair &outDimTags, const bool combined, const bool oriented, const bool recursive) @@ -356,19 +342,24 @@ GMSH_API gmshModelMesh(int dim) GMSH_API gmshModelGetMeshVertices(const int dim, const int tag, std::vector<int> &vertexTags, - std::vector<double> &coords) + std::vector<double> &coordinates, + std::vector<double> ¶metricCoordinates) { if(!_isInitialized()) return GMSH_ERROR(-1); vertexTags.clear(); - coords.clear(); + coordinates.clear(); GEntity *ge = GModel::current()->getEntityByTag(dim, tag); if(!ge) return GMSH_ERROR(1); for(unsigned int i = 0; i < ge->mesh_vertices.size(); i++){ MVertex *v = ge->mesh_vertices[i]; vertexTags.push_back(v->getNum()); - coords.push_back(v->x()); - coords.push_back(v->y()); - coords.push_back(v->z()); + coordinates.push_back(v->x()); + coordinates.push_back(v->y()); + coordinates.push_back(v->z()); + double par; + for(int j = 0; j < dim; j++){ + if(v->getParameter(j, par)) parametricCoordinates.push_back(par); + } } return GMSH_OK; } diff --git a/Common/gmsh.h b/Common/gmsh.h index ece85a799e..f023ab6d83 100644 --- a/Common/gmsh.h +++ b/Common/gmsh.h @@ -61,8 +61,6 @@ GMSH_API gmshModelSetPhysicalName(const int dim, const int tag, const std::string &name); GMSH_API gmshModelGetPhysicalName(const int dim, const int tag, std::string &name); -GMSH_API gmshModelGetVertexCoordinates(const int tag, double &x, double &y, - double &z); GMSH_API gmshModelGetBoundary(const vector_pair &inDimTags, vector_pair &outDimTags, const bool combined = true, const bool oriented = true, const bool recursive = false); @@ -76,7 +74,8 @@ GMSH_API gmshModelRemove(const vector_pair &dimTags, const bool recursive = fals GMSH_API gmshModelMesh(const int dim); GMSH_API gmshModelGetMeshVertices(const int dim, const int tag, std::vector<int> &vertexTags, - std::vector<double> &coords); + std::vector<double> &coordinates, + std::vector<double> ¶metricCoordinates); GMSH_API gmshModelGetMeshElements(const int dim, const int tag, std::vector<int> &types, std::vector<std::vector<int> > &elementTags, diff --git a/demos/api/explore.cpp b/demos/api/explore.cpp index 6b068c895e..24e7a760f5 100644 --- a/demos/api/explore.cpp +++ b/demos/api/explore.cpp @@ -21,9 +21,9 @@ int main(int argc, char **argv) // get the mesh vertices for each elementary entity std::vector<int> vertexTags; - std::vector<double> vertexCoords; + std::vector<double> vertexCoords, vertexParams; int dim = entities[i].first, tag = entities[i].second; - gmshModelGetMeshVertices(dim, tag, vertexTags, vertexCoords); + gmshModelGetMeshVertices(dim, tag, vertexTags, vertexCoords, vertexParams); // get the mesh elements for each elementary entity std::vector<int> elemTypes; diff --git a/demos/api/explore.py b/demos/api/explore.py index 5bec30b80c..a817fb07c3 100644 --- a/demos/api/explore.py +++ b/demos/api/explore.py @@ -4,7 +4,7 @@ from gmsh import * import sys if len(sys.argv) < 2: - print "Usage: basic.py file.geo [options]" + print "Usage: " + sys.argv[0] + " file.geo [options]" exit(0) gmshInitialize() @@ -19,8 +19,8 @@ gmshModelGetEntities(entities) for e in entities: # get the mesh vertices for each elementary entity vertexTags = IntVector() - vertexCoords = DoubleVector() - gmshModelGetMeshVertices(e[0], e[1], vertexTags, vertexCoords) + vertexCoords = DoubleVector(); vertexParams = DoubleVector() + gmshModelGetMeshVertices(e[0], e[1], vertexTags, vertexCoords, vertexParams) # get the mesh elements for each elementary entity elemTypes = IntVector() elemTags = IntVectorVector(); elemVertexTags = IntVectorVector() diff --git a/demos/api/open.py b/demos/api/open.py index 968d905f78..4f09a068f2 100644 --- a/demos/api/open.py +++ b/demos/api/open.py @@ -4,7 +4,7 @@ from gmsh import * import sys if len(sys.argv) < 2: - print "Usage: basic.py file.geo [options]" + print "Usage: " + sys.argv[0] + " file.geo [options]" exit(0) gmshInitialize() diff --git a/demos/api/t1.cpp b/demos/api/t1.cpp index 522b7ee2f4..1d5f3f23e0 100644 --- a/demos/api/t1.cpp +++ b/demos/api/t1.cpp @@ -1,7 +1,8 @@ -// This file reimplements gmsh/tutorial/t1.geo in C++. For all the elementary -// explanations about the general philosphy of entities in Gmsh, see the -// comments in the .geo file. Comments here focus on the specifics of the C++ -// API. +// This file reimplements gmsh/tutorial/t1.geo in C++. + +// For all the elementary explanations about the general philosphy of entities +// in Gmsh, see the comments in the .geo file. Comments here focus on the +// specifics of the C++ API. // The Gmsh API is entirely defined in the <gmsh.h> header: #include <gmsh.h> diff --git a/demos/api/t1.py b/demos/api/t1.py index 532a0d8899..dc8a5940eb 100644 --- a/demos/api/t1.py +++ b/demos/api/t1.py @@ -1,8 +1,10 @@ #!/usr/bin/env python -# This file reimplements gmsh/tutorial/t1.geo in Python. For all the elementary -# explanations about the general philosphy of entities in Gmsh, see the comments -# in the .geo file. Comments here focus on the specifics of the Python API. +# This file reimplements gmsh/tutorial/t1.geo in Python. + +# For all the elementary explanations about the general philosphy of entities in +# Gmsh, see the comments in the .geo file. Comments here focus on the specifics +# of the Python API. # The API is entirely defined in the gmsh module from gmsh import * diff --git a/demos/api/t2.cpp b/demos/api/t2.cpp index b60e48a6ca..f7e60ab0c7 100644 --- a/demos/api/t2.cpp +++ b/demos/api/t2.cpp @@ -44,7 +44,7 @@ int main(int argc, char **argv) // The "Duplicata" functionality in .geo files is handled by // gmshModelGeoCopy(), which takes a vector of (dim, tag) pairs as input, and // returns another vector of (dim, tag) pairs. - std::vector<std::pair<int, int> > ov, ov2; + std::vector<std::pair<int, int> > ov; gmshModelGeoCopy({{0, 3}}, ov); gmshModelGeoTranslate(ov, 0, 0.1, 0); @@ -90,6 +90,7 @@ int main(int argc, char **argv) // Extrusion works as expected, by providing a vector of (dim, tag) pairs as // input, the translation vector, and a vector of (dim, tag) pairs as output. + std::vector<std::pair<int, int> > ov2; gmshModelGeoExtrude({ov[1]}, 0, 0, 0.12, ov2); // Mesh sizes associated to geometrical points can be set by passing a vector -- GitLab