diff --git a/Common/LuaBindings.cpp b/Common/LuaBindings.cpp index 887f4e9249ce52c752ae5d9cb2cdb7beef361dd0..59c8efd109cc21b568dc83806d335dc991d01bd4 100644 --- a/Common/LuaBindings.cpp +++ b/Common/LuaBindings.cpp @@ -319,31 +319,32 @@ binding::binding(){ // lua_pushcfunction(L, luaopen_io); // lua_call(L, 0, 0); - - // Register Lua bindings + DocRecord::registerBindings(this); + GEdge::registerBindings(this); + GEntity::registerBindings(this); + GFace::registerBindings(this); GModel::registerBindings(this); - fullMatrix<double>::registerBindings(this); - function::registerBindings(this); - dgGroupCollection::registerBindings(this); - dgDofContainer::registerBindings(this); - dgRungeKutta::registerBindings(this); - dgLimiter::registerBindings(this); - dgSlopeLimiterRegisterBindings(this); + GRegion::registerBindings(this); + GVertex::registerBindings(this); + MElement::registerBindings(this); + MVertex::registerBindings(this); dgBoundaryCondition::registerBindings(this); dgConservationLaw::registerBindings(this); + dgConservationLawAdvectionDiffusionRegisterBindings(this); dgConservationLawShallowWater2dRegisterBindings(this); dgConservationLawWaveEquationRegisterBindings(this); - dgConservationLawAdvectionDiffusionRegisterBindings(this); + dgDofContainer::registerBindings(this); + dgGroupCollection::registerBindings(this); + dgLimiter::registerBindings(this); dgPerfectGasLaw2dRegisterBindings(this); + dgRungeKutta::registerBindings(this); + dgSlopeLimiterRegisterBindings(this); dgSystemOfEquations::registerBindings(this); - functionLua::registerBindings(this); + fullMatrix<double>::registerBindings(this); + function::registerBindings(this); function::registerDefaultFunctions(); - MVertex::registerBindings(this); - MElement::registerBindings(this); - DocRecord::registerBindings(this); - GEntity::registerBindings(this); - GFace::registerBindings(this); + functionLua::registerBindings(this); gmshOptions::registerBindings(this); } binding *binding::_instance=NULL; diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp index 4aa0af1655726fc1ef98b2ef48a3aa6f790ccbdd..e79c59f400b58e558e748b567872b1d6a9fc6f74 100644 --- a/Geo/GEdge.cpp +++ b/Geo/GEdge.cpp @@ -14,6 +14,7 @@ #include "MLine.h" #include "GaussLegendre1D.h" #include "Context.h" +#include "bindings.h" GEdge::GEdge(GModel *model, int tag, GVertex *_v0, GVertex *_v1) : GEntity(model, tag), _tooSmall(false), v0(_v0), v1(_v1), compound(0) @@ -344,3 +345,10 @@ bool GEdge::XYZToU(const double X, const double Y, const double Z, Q.x(), Q.y(), Q.z(), tag()); return false; } + +void GEdge::registerBindings(binding *b) +{ + classBinding *cb = b->addClass<GEdge>("GEdge"); + cb->setDescription("A GEdge is a geometrical 1D entity"); + cb->setParentClass<GEntity>(); +} diff --git a/Geo/GEdge.h b/Geo/GEdge.h index 7f2ef2804521707f1aa3225ee89bab089d774c75..9bfddfd5783b83206c6dadb5df24115df27d83d2 100644 --- a/Geo/GEdge.h +++ b/Geo/GEdge.h @@ -183,6 +183,7 @@ class GEdge : public GEntity { std::vector<MLine*> lines; + static void registerBindings(binding *b); }; #endif diff --git a/Geo/GEntity.cpp b/Geo/GEntity.cpp index abd2baef4a92da0e581c18bb28a88848094d5152..4da5d78e31806355b8c9cfdc2607a3b813d6d4bc 100644 --- a/Geo/GEntity.cpp +++ b/Geo/GEntity.cpp @@ -9,6 +9,7 @@ #include "MElement.h" #include "VertexArray.h" #include "Context.h" +#include "Bindings.h" GEntity::GEntity(GModel *m, int t) : _model(m), _tag(t), _visible(1), _selection(0), @@ -60,24 +61,21 @@ std::string GEntity::getInfoString() return sstream.str(); } -#include "Bindings.h" - void GEntity::registerBindings(binding *b) { classBinding *cb = b->addClass<GEntity>("GEntity"); cb->setDescription("A GEntity is a geometrical entity of the model."); - - methodBinding *cm; - cm = cb->addMethod("model", &GEntity::model); - cm->setDescription("returns the geometric model the entity belongs to."); - - /* - cm = cb->addMethod("getNumMeshElements", (unsigned int (GEntity::*)() ) &GEntity::getNumMeshElements); - cm->setDescription("Return the number of elements of the mesh of the entity."); - cm = cb->addMethod("getMeshElement", &GEntity::getMeshElement); - cm->setDescription("returns the ith MElement."); - cm->setArgNames("i",NULL); - */ - + methodBinding *mb; + mb = cb->addMethod("getNumMeshElements",(unsigned int (GEntity::*)())&GEntity::getNumMeshElements); + mb->setDescription("return the number of mesh elements in this entity"); + mb = cb->addMethod("getMeshElement",&GEntity::getMeshElement); + mb->setDescription("get the mesh element at the given index"); + mb->setArgNames("index",NULL); + mb = cb->addMethod("getNumMeshVertices",(unsigned int (GEntity::*)())&GEntity::getNumMeshVertices); + mb->setDescription("return the number of mesh vertices in this entity"); + mb = cb->addMethod("getMeshVertex",&GEntity::getMeshVertex); + mb->setDescription("get the mesh vertex at the given index"); + mb->setArgNames("index",NULL); + mb = cb->addMethod("model", &GEntity::model); + mb->setDescription("returns the geometric model the entity belongs to."); } - diff --git a/Geo/GEntity.h b/Geo/GEntity.h index a4d2f2d59370e8c090383f0ad20b3ec72964d166..6dadf2b107094fc9762beb32d6914b5ba638b195 100644 --- a/Geo/GEntity.h +++ b/Geo/GEntity.h @@ -270,7 +270,6 @@ class GEntity { // bindings static void registerBindings(binding *b); - }; class GEntityLessThan { diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index e1f4a904ef0084f53ad4adb0bb99caac3da3b512..d564aa42cf293a9e3e8866cc10e65bae6de84ac9 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -18,6 +18,7 @@ #include "GaussLegendre1D.h" #include "Context.h" #include "meshGFaceLloyd.h" +#include "bindings.h" #define SQU(a) ((a)*(a)) @@ -1059,10 +1060,9 @@ void GFace::registerBindings(binding *b) { classBinding *cb = b->addClass<GFace>("GFace"); cb->setParentClass<GEntity>(); - cb->setDescription("A Geometrical Face."); + cb->setDescription("A GFace is a geometrical 2D entity"); methodBinding *cm; cm = cb->addMethod("lloyd", &GFace::lloyd); cm->setDescription("do N iteration of Lloyd's algorithm using or not the infinite norm"); cm->setArgNames("N","infiniteNorm",NULL); } - diff --git a/Geo/GFace.h b/Geo/GFace.h index 09a2f988e254857d5da33a5ea38c0d2a176e3b49..df51d9c963193928e91801a2c1b1fa77365ddc05 100644 --- a/Geo/GFace.h +++ b/Geo/GFace.h @@ -296,7 +296,6 @@ class GFace : public GEntity // After mesh generation, those are moved to the mesh_vertices array std::vector<MVertex*> _additional_vertices; - static void registerBindings(binding *b); }; diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 2b5700d570f549a19ffed7d0e71d05ee478595c0..5aff9d50c49dc8f785cdb9ca66ae96476445ff42 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -1373,9 +1373,26 @@ void GModel::registerBindings(binding *b) cm = cb->addMethod("getMeshVertexByTag",&GModel::getMeshVertexByTag); cm->setDescription("access a mesh vertex by tag, using the vertex cache"); cm->setArgNames("tag",NULL); + cm = cb->addMethod("getNumRegions",&GModel::getNumRegions); + cm->setDescription("return the number of rgions (3D geometrical entities)"); + cm = cb->addMethod("getNumFaces",&GModel::getNumFaces); + cm->setDescription("return the number of faces (2D geometrical entities)"); + cm = cb->addMethod("getNumEdges",&GModel::getNumEdges); + cm->setDescription("return the number of edges (1D geometrical entities)"); + cm = cb->addMethod("getNumVertices",&GModel::getNumVertices); + cm->setDescription("return the number of vertices (0D geometrical entities)"); cm = cb->addMethod("getFaceByTag",&GModel::getFaceByTag); - cm->setDescription("access a model face by its tag"); + cm->setDescription("access a geometrical face by tag"); + cm->setArgNames("tag",NULL); + cm = cb->addMethod("getEdgeByTag",&GModel::getEdgeByTag); + cm->setDescription("access a geometrical edge by tag"); + cm->setArgNames("tag",NULL); + cm = cb->addMethod("getVertexByTag",&GModel::getVertexByTag); + cm->setDescription("access a geometrical vertex by tag"); + cm->setArgNames("tag",NULL); + cm = cb->addMethod("getRegionByTag",&GModel::getRegionByTag); + cm->setDescription("access a geometrical region by tag"); cm->setArgNames("tag",NULL); cm = cb->setConstructor<GModel>(); - cm->setDescription("Create an empty GModel."); + cm->setDescription("Create an empty GModel"); } diff --git a/Geo/GRegion.cpp b/Geo/GRegion.cpp index a09843cc7648e534a860cafe813a1c8af25270a6..e2f61d6b6be4c3fe657e6932f9df4777bb6a6859 100644 --- a/Geo/GRegion.cpp +++ b/Geo/GRegion.cpp @@ -14,6 +14,7 @@ #include "MElementCut.h" #include "GmshMessage.h" #include "VertexArray.h" +#include "bindings.h" GRegion::GRegion(GModel *model, int tag) : GEntity (model, tag) { @@ -257,3 +258,10 @@ bool GRegion::edgeConnected(GRegion *r) const } return false; } + +void GRegion::registerBindings(binding *b) +{ + classBinding *cb = b->addClass<GRegion>("GRegion"); + cb->setDescription("A GRegion is a geometrical 3D entity"); + cb->setParentClass<GEntity>(); +} diff --git a/Geo/GRegion.h b/Geo/GRegion.h index e7a8ec8bb564c463ce91cdfb479b76d6d9e4f653..65e6116e12660e1506d1aaa2fd3f6c9ae21f70bf 100644 --- a/Geo/GRegion.h +++ b/Geo/GRegion.h @@ -19,6 +19,7 @@ class MPrism; class MPyramid; class MPolyhedron; class ExtrudeParams; +class bindings; // A model region. class GRegion : public GEntity { @@ -96,6 +97,8 @@ class GRegion : public GEntity { std::vector<MPrism*> prisms; std::vector<MPyramid*> pyramids; std::vector<MPolyhedron*> polyhedra; + + static void registerBindings(binding *b); }; #endif diff --git a/Geo/GVertex.cpp b/Geo/GVertex.cpp index 206abc95151bff40e831ceef8700faab0be64096..69cc0a843c8a7d14d78c386602e85ad57b90880d 100644 --- a/Geo/GVertex.cpp +++ b/Geo/GVertex.cpp @@ -10,6 +10,7 @@ #include "GFace.h" #include "MPoint.h" #include "GmshMessage.h" +#include "bindings.h" GVertex::GVertex(GModel *m, int tag, double ms) : GEntity(m, tag), meshSize(ms) { @@ -85,3 +86,10 @@ bool GVertex::isOnSeam(const GFace *gf) const } return false; } + +void GVertex::registerBindings(binding *b) +{ + classBinding *cb = b->addClass<GVertex>("GVertex"); + cb->setDescription("A GVertex is a geometrical 0D entity"); + cb->setParentClass<GEntity>(); +} diff --git a/Geo/GVertex.h b/Geo/GVertex.h index 459a8a3f7b3a16f8266c007e3b2be3bd8e820e85..73a8c8911a5f32445d697d57bc115fb862b69874 100644 --- a/Geo/GVertex.h +++ b/Geo/GVertex.h @@ -78,7 +78,8 @@ class GVertex : public GEntity bool isOnSeam(const GFace *gf) const; std::vector<MPoint*> points; - + + static void registerBindings(binding *b); }; #endif diff --git a/Geo/MVertex.cpp b/Geo/MVertex.cpp index 4e7f84dbf9296f31bbca5a675eefddfc1b61b517..77d8c51b8436a2ddf8d115c604a1a969150c319d 100644 --- a/Geo/MVertex.cpp +++ b/Geo/MVertex.cpp @@ -414,6 +414,9 @@ void MVertex::registerBindings(binding *b) cm->setDescription("Return the y-coordinate."); cm = cb->addMethod("z", (double (MVertex::*)() const) &MVertex::z); cm->setDescription("Return the z-coordinate."); + cm = cb->addMethod("setXYZ", &MVertex::setXYZ); + cm->setDescription("set the coordinates"); + cm->setArgNames("x","y","z",NULL); cm = cb->setConstructor<MVertex,double,double,double>(); cm->setArgNames("x","y","z",NULL); cm->setDescription("Create a new mesh vertex at (x,y,z)."); diff --git a/Geo/MVertex.h b/Geo/MVertex.h index c41f4f822876dee437e4b3646ec6f6bcf344b697..71099135699a38087c0b5799b2aaa7e4f9bee301 100644 --- a/Geo/MVertex.h +++ b/Geo/MVertex.h @@ -67,6 +67,9 @@ class MVertex{ inline double & x() { return _x; } inline double & y() { return _y; } inline double & z() { return _z; } + // cannot use the reference to set the value in the bindings + inline void setXYZ(double x,double y, double z) {_x=x; _y=y; _z=z; } + inline SPoint3 point() const { return SPoint3(_x, _y, _z); } // get/set the parent entity