diff --git a/CMakeLists.txt b/CMakeLists.txt index 38be60d0cf392f44126b98e75f27959a8aed232d..7fd311be9a12bd6fa3e5809d62556527bce84446 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1252,7 +1252,7 @@ if(ENABLE_WRAP_PYTHON) find_package(PythonLibs) if(SWIG_FOUND AND PYTHONLIBS_FOUND) message(STATUS "Found SWIG version " ${SWIG_VERSION}) - if(NOT DEPRECATED_API) # new bindings + if(NOT ENABLE_DEPRECATED_API) # new bindings include_directories(${PYTHON_INCLUDE_PATH}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_SWIG_FLAGS "") @@ -1263,7 +1263,7 @@ if(ENABLE_WRAP_PYTHON) set_target_properties("_gmsh" PROPERTIES LINK_FLAGS "-undefined suppress -flat_namespace") endif(APPLE) - else(NOT DEPRECATED_API) # old, deprecated internal developer bindings + else(NOT ENABLE_DEPRECATED_API) # old, deprecated internal developer bindings find_package(PythonInterp) string(SUBSTRING ${SWIG_VERSION} 0 1 SWIG_MAJOR_VERSION) if(SWIG_MAJOR_VERSION EQUAL 1) @@ -1299,16 +1299,16 @@ if(ENABLE_WRAP_PYTHON) endif(ENABLE_PETSC4PY) endif(HAVE_PETSC) endif(SWIG_MAJOR_VERSION EQUAL 1) - endif(NOT DEPRECATED_API) + endif(NOT ENABLE_DEPRECATED_API) endif(SWIG_FOUND AND PYTHONLIBS_FOUND) endif(ENABLE_WRAP_PYTHON) -if(ENABLE_WRAP_JAVA AND DEPRECATED_API) +if(ENABLE_WRAP_JAVA AND ENABLE_DEPRECATED_API) if(NOT HAVE_BLAS OR NOT HAVE_LAPACK) message(WARNING "Java wrapping samples will not work without BLAS and LAPACK") endif(NOT HAVE_BLAS OR NOT HAVE_LAPACK) add_subdirectory(wrappers/java) -endif(ENABLE_WRAP_JAVA AND DEPRECATED_API) +endif(ENABLE_WRAP_JAVA AND ENABLE_DEPRECATED_API) check_function_exists(vsnprintf HAVE_VSNPRINTF) if(NOT HAVE_VSNPRINTF AND NOT ENABLE_BUILD_IOS AND NOT ENABLE_BUILD_ANDROID) diff --git a/Common/gmsh.cpp b/Common/gmsh.cpp index 2b3a7007d1163b56c4bad4f855dd45a68658af6f..db5b92dbe68f4583089c3a7b9080f2a3b8a6bfec 100644 --- a/Common/gmsh.cpp +++ b/Common/gmsh.cpp @@ -423,10 +423,10 @@ int gmshModelSetReverseMesh(int dim, int tag) return 0; } -int gmshModelAddEmbedded(int dim, const std::vector<int> &tags, int toDim, int toTag) +int gmshModelEmbed(int dim, const std::vector<int> &tags, int inDim, int inTag) { - if(toDim == 2){ - GFace *gf = GModel::current()->getFaceByTag(toTag); + if(inDim == 2){ + GFace *gf = GModel::current()->getFaceByTag(inTag); if(gf){ for(unsigned int i = 0; i < tags.size(); i++){ if(dim == 0){ @@ -442,8 +442,8 @@ int gmshModelAddEmbedded(int dim, const std::vector<int> &tags, int toDim, int t } } } - else if(toDim == 3){ - GRegion *gr = GModel::current()->getRegionByTag(toTag); + else if(inDim == 3){ + GRegion *gr = GModel::current()->getRegionByTag(inTag); if(gr){ for(unsigned int i = 0; i < tags.size(); i++){ if(dim == 0){ @@ -640,7 +640,7 @@ int gmshModelGeoSynchronize() return 0; } -// gmshModelOCC +// gmshModelOcc static void createOcc() { @@ -652,3 +652,10 @@ int gmshModelOccAddVertex(int &tag, double x, double y, double z, double meshSiz createOcc(); return !GModel::current()->getOCCInternals()->addVertex(tag, x, y, z, meshSize); } + +int gmshModelGeoSynchronize() +{ + createOcc(); + GModel::current()->getOccInternals()->synchronize(GModel::current()); + return 0; +} diff --git a/Common/gmsh.h b/Common/gmsh.h index 0e7eb98edb4d5735319eb8ae97e3c76f2deda0c5..5b1d083d6ba03c28476e4b167acb463299727aeb 100644 --- a/Common/gmsh.h +++ b/Common/gmsh.h @@ -29,7 +29,7 @@ #endif // gmsh -GMSH_API gmshInitialize(int argc=0, char **argv=0); +GMSH_API gmshInitialize(int argc = 0, char **argv = 0); GMSH_API gmshFinalize(); GMSH_API gmshOpen(const std::string &fileName); GMSH_API gmshMerge(const std::string &fileName); @@ -49,21 +49,22 @@ GMSH_API gmshModelDestroy(); GMSH_API gmshModelGetEntities(std::vector<std::pair<int, int> > &dimTags); GMSH_API gmshModelGetPhysicalGroups(std::vector<std::pair<int, int> > &dimTags); GMSH_API gmshModelAddPhysicalGroup(int dim, int tag, const std::vector<int> &tags); -GMSH_API gmshModelGetEntitiesForPhysicalGroup(int dim, int tag, std::vector<int> &tags); +GMSH_API gmshModelGetEntitiesForPhysicalGroup(int dim, int tag, + std::vector<int> &tags); GMSH_API gmshModelSetPhysicalName(int dim, int tag, const std::string &name); GMSH_API gmshModelGetPhysicalName(int dim, int tag, std::string &name); -GMSH_API gmshModelGetVertexCoordinates(int tag, std::vector<double> &coord); +GMSH_API gmshModelGetVertexCoordinates(int tag, double &x, double &y, double &z); GMSH_API gmshModelGetBoundary(const std::vector<std::pair<int, int> > &inDimTags, std::vector<std::pair<int, int> > &outDimTags, - bool combined=true, bool oriented=true, - bool recursive=false); + bool combined = true, bool oriented = true, + bool recursive = false); GMSH_API gmshModelGetEntitiesInBoundingBox(int dim, double x1, double y1, double z1, double x2, double y2, double z2, std::vector<int> &tags); GMSH_API gmshModelGetBoundingBox(int dim, int tag, double &x1, double &y1, double &z1, double &x2, double &y2, double &z2); GMSH_API gmshModelRemove(const std::vector<std::pair<int, int> > &dimTags, - bool recursive=false); + bool recursive = false); GMSH_API gmshModelMesh(int dim); GMSH_API gmshModelGetMeshVertices(int dim, int tag, std::vector<int> &vertexTags, std::vector<double> &coords); @@ -78,51 +79,52 @@ GMSH_API gmshModelSetTransfiniteVolume(int tag, const std::vector<int> &cornerTa GMSH_API gmshModelSetRecombine(int dim, int tag, double angle); GMSH_API gmshModelSetSmoothing(int tag, int val); GMSH_API gmshModelSetReverseMesh(int dim, int tag); -GMSH_API gmshModelAddEmbedded(int dim, const std::vector<int> &tags, - int toDim, int toTag); +GMSH_API gmshModelEmbed(int dim, const std::vector<int> &tags, int inDim, int inTag); // gmshModelGeo -GMSH_API gmshModelGeoAddVertex(int &tag, double x, double y, double z, double meshSize); +GMSH_API gmshModelGeoAddVertex(int &tag, double x, double y, double z, + double meshSize); GMSH_API gmshModelGeoAddLine(int &tag, int startTag, int endTag); GMSH_API gmshModelGeoAddCircleArc(int &tag, int startTag, int centerTag, int endTag, - double nx=0., double ny=0., double nz=0.); -GMSH_API gmshModelGeoAddEllipseArc(int &tag, int startTag, int centerTag, int majorTag, - int endTag, double nx=0., double ny=0., double nz=0.); + double nx = 0., double ny = 0., double nz = 0.); +GMSH_API gmshModelGeoAddEllipseArc(int &tag, int startTag, int centerTag, + int majorTag, int endTag, double nx = 0., + double ny = 0., double nz = 0.); GMSH_API gmshModelGeoAddSpline(int &tag, const std::vector<int> &vertexTags); GMSH_API gmshModelGeoAddBSpline(int &tag, const std::vector<int> &vertexTags); GMSH_API gmshModelGeoAddBezier(int &tag, const std::vector<int> &vertexTags); GMSH_API gmshModelGeoAddLineLoop(int &tag, const std::vector<int> &edgeTags); GMSH_API gmshModelGeoAddPlaneSurface(int &tag, const std::vector<int> &wireTags); GMSH_API gmshModelGeoAddSurfaceFilling(int &tag, const std::vector<int> &wireTags, - int sphereCenterTag=-1); + int sphereCenterTag = -1); GMSH_API gmshModelGeoAddSurfaceLoop(int &tag, const std::vector<int> &faceTags); GMSH_API gmshModelGeoAddVolume(int &tag, const std::vector<int> &shellTags); GMSH_API gmshModelGeoExtrude(const std::vector<std::pair<int, int> > &inDimTags, double dx, double dy, double dz, std::vector<std::pair<int, int> > &outDimTags, - const std::vector<int> &numElements=std::vector<int>(), - const std::vector<double> &heights=std::vector<double>(), - bool recombine=false); + const std::vector<int> &numElements = std::vector<int>(), + const std::vector<double> &heights = std::vector<double>(), + bool recombine = false); GMSH_API gmshModelGeoRevolve(const std::vector<std::pair<int, int> > &inDimTags, double x, double y, double z, double ax, double ay, double az, double angle, std::vector<std::pair<int, int> > &outDimTags, - const std::vector<int> &numElements=std::vector<int>(), - const std::vector<double> &heights=std::vector<double>(), - bool recombine=false); + const std::vector<int> &numElements = std::vector<int>(), + const std::vector<double> &heights = std::vector<double>(), + bool recombine = false); GMSH_API gmshModelGeoTwist(const std::vector<std::pair<int, int> > &inDimTags, double x, double y, double z, double dx, double dy, double dz, double ax, double ay, double az, double angle, std::vector<std::pair<int, int> > &outDimTags, - const std::vector<int> &numElements=std::vector<int>(), - const std::vector<double> &heights=std::vector<double>(), - bool recombine=false); + const std::vector<int> &numElements = std::vector<int>(), + const std::vector<double> &heights = std::vector<double>(), + bool recombine = false); GMSH_API gmshModelGeoTranslate(const std::vector<std::pair<int, int> > &dimTags, double dx, double dy, double dz); GMSH_API gmshModelGeoRotate(const std::vector<std::pair<int, int> > &dimTags, - double x, double y, double z, double ax, double ay, double az, - double angle); + double x, double y, double z, double ax, double ay, + double az, double angle); GMSH_API gmshModelGeoDilate(const std::vector<std::pair<int, int> > &dimTags, double x, double y, double z, double a, double b, double c); @@ -131,12 +133,13 @@ GMSH_API gmshModelGeoSymmetry(const std::vector<std::pair<int, int> > &dimTags, GMSH_API gmshModelGeoCopy(const std::vector<std::pair<int, int> > &inDimTags, std::vector<std::pair<int, int> > &outDimTags); GMSH_API gmshModelGeoRemove(const std::vector<std::pair<int, int> > &dimTags, - bool recursive=false); + bool recursive = false); GMSH_API gmshModelGeoRemoveAllDuplicates(); GMSH_API gmshModelGeoSynchronize(); // gmshModelOcc -GMSH_API gmshModelOccAddVertex(int &tag, double x, double y, double z, double meshSize); +GMSH_API gmshModelOccAddVertex(int &tag, double x, double y, double z, + double meshSize); // gmshSolver diff --git a/demos/api/README.txt b/demos/api/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..91d6430a2855cab261b177607fcffb3af6cdf7a4 --- /dev/null +++ b/demos/api/README.txt @@ -0,0 +1,2 @@ +This directory contains examples on how to use the Gmsh C++ API. + diff --git a/demos/api/t1.cpp b/demos/api/t1.cpp index 3d107e12a2fadc06aaf0968dad4241f77f749e4e..5cdfe77a83c6ddcaed35f6daaa2d33fa11c02bdc 100644 --- a/demos/api/t1.cpp +++ b/demos/api/t1.cpp @@ -1,4 +1,3 @@ -#include <iostream> #include <gmsh.h> // this reimplements gmsh/tutorial/t1.geo