diff --git a/Common/LuaBindings.cpp b/Common/LuaBindings.cpp index 8668c7d903ce468002e99db63b2da7be9d8bc7fe..2cdc12e9a29ab488be00d72f6fcd399e348504e8 100644 --- a/Common/LuaBindings.cpp +++ b/Common/LuaBindings.cpp @@ -16,6 +16,10 @@ #include "Context.h" #include "MVertex.h" #include "MElement.h" +#include "MTriangle.h" +#include "MQuadrangle.h" +#include "MPrism.h" +#include "MLine.h" #include "GFace.h" #include "DivideAndConquer.h" #include "Bindings.h" @@ -383,6 +387,10 @@ binding::binding() GModel::registerBindings(this); MElement::registerBindings(this); MVertex::registerBindings(this); + MTriangle::registerBindings(this); + MPrism::registerBindings(this); + MQuadrangle::registerBindings(this); + MLine::registerBindings(this); fullMatrix<double>::registerBindings(this); gmshOptions::registerBindings(this); Msg::registerBindings(this); diff --git a/Common/LuaBindings.h b/Common/LuaBindings.h index 8b004722e6ebc18a12b90338bec222876ef3524d..d5f81778a0d49481f1ffd2d03f3354faedecf897 100644 --- a/Common/LuaBindings.h +++ b/Common/LuaBindings.h @@ -12,6 +12,7 @@ #include <map> #include <vector> +#include <list> #include <set> #include "GmshConfig.h" #include "GmshMessage.h" @@ -44,7 +45,6 @@ class className{ template<typename type> std::string className<type>::_name; -template <> template <typename t> class className<t*>{ public: @@ -137,7 +137,7 @@ class luaStack<std::vector<type > >{ static void push(lua_State *L, const std::vector<type>& v) { lua_createtable(L, v.size(), 0); - for(size_t i = 0; i < v.size; i++){ + for(size_t i = 0; i < v.size(); i++){ luaStack<type>::push(L, v[i]); lua_rawseti(L, 2, i + 1); } @@ -148,6 +148,35 @@ class luaStack<std::vector<type > >{ return name + luaStack<type>::getName(); } }; +template<class lType> +class luaStack<std::list<lType > >{ + public: + static std::list<lType> get(lua_State *L, int ia) + { + std::list<lType> l; + size_t size = lua_objlen(L, ia); + for(size_t i = 0; i < size; i++){ + lua_rawgeti(L, ia, i + 1); + l.push_back(luaStack<lType>::get(L, -1)); + lua_pop(L, 1); + } + return l; + } + static void push(lua_State *L, const std::list<lType>& l) + { + std::vector<lType> v(l.begin(), l.end()); + lua_createtable(L, v.size(), 0); + for(size_t i = 0; i < v.size(); i++){ + luaStack<lType>::push(L, v[i]); + lua_rawseti(L, 2, i + 1); + } + } + static std::string getName() + { + std::string name = "list of "; + return name + luaStack<lType>::getName(); + } +}; template<class type> class luaStack<std::vector<type> &>{ @@ -178,6 +207,35 @@ class luaStack<std::vector<type> &>{ return name + luaStack<type>::getName(); } }; +template<class lType> +class luaStack<std::list<lType > &>{ + public: + static std::list<lType> get(lua_State *L, int ia) + { + std::list<lType> l; + size_t size = lua_objlen(L, ia); + for(size_t i = 0; i < size; i++){ + lua_rawgeti(L, ia, i + 1); + l.push_back(luaStack<lType>::get(L, -1)); + lua_pop(L, 1); + } + return l; + } + static void push(lua_State *L, const std::list<lType>& l) + { + std::vector<lType> v(l.begin(), l.end()); + lua_createtable(L, v.size(), 0); + for(size_t i = 0; i < v.size(); i++){ + luaStack<lType>::push(L, v[i]); + lua_rawseti(L, 2, i + 1); + } + } + static std::string getName() + { + std::string name = "list of "; + return name + luaStack<lType>::getName(); + } +}; template<> class luaStack<double>{ @@ -1038,9 +1096,8 @@ class methodBindingT :public luaMethodBinding { int call(lua_State *L){ return luaCall(L, _f); } void getArgTypeNames(std::vector<std::string> &names){ argTypeNames<cb>::get(names); } }; - template <typename tObj, typename t0=void, typename t1=void, typename t2=void, - typename t3=void, typename t4=void> + typename t3=void, typename t4=void, typename t5=void> class constructorBindingT: public luaMethodBinding { public: int call(lua_State *L) @@ -1048,17 +1105,18 @@ class constructorBindingT: public luaMethodBinding { lua_remove(L, 1); (luaStack<tObj*>::push(L, new tObj(luaStack<t0>::get(L, 1), luaStack<t1>::get(L, 2), luaStack<t2>::get(L, 3), luaStack<t3>::get(L, 4), - luaStack<t4>::get(L, 5)))); + luaStack<t4>::get(L, 5), luaStack<t5>::get(L, 6)))); return 1; } void getArgTypeNames(std::vector<std::string> &names) { - argTypeNames<void (tObj::*)(t0, t1, t2, t3, t4)>::get(names); + argTypeNames<void (tObj::*)(t0, t1, t2, t3, t4, t5)>::get(names); } }; + template <typename tObj> -class constructorBindingT<tObj, void, void, void, void> : public luaMethodBinding { +class constructorBindingT<tObj, void, void, void, void,void> : public luaMethodBinding { public: int call(lua_State *L) { @@ -1073,7 +1131,7 @@ class constructorBindingT<tObj, void, void, void, void> : public luaMethodBindin }; template <typename tObj, typename t0> -class constructorBindingT<tObj, t0, void, void, void, void> : public luaMethodBinding { +class constructorBindingT<tObj, t0, void, void, void, void,void> : public luaMethodBinding { public: int call(lua_State *L) { @@ -1087,7 +1145,7 @@ class constructorBindingT<tObj, t0, void, void, void, void> : public luaMethodBi }; template <typename tObj, typename t0, typename t1> -class constructorBindingT<tObj, t0, t1, void, void, void> : public luaMethodBinding { +class constructorBindingT<tObj, t0, t1, void, void, void,void> : public luaMethodBinding { public: int call(lua_State *L) { @@ -1102,7 +1160,7 @@ class constructorBindingT<tObj, t0, t1, void, void, void> : public luaMethodBind }; template <typename tObj, typename t0, typename t1, typename t2> -class constructorBindingT<tObj, t0, t1, t2, void, void> : public luaMethodBinding { +class constructorBindingT<tObj, t0, t1, t2, void, void,void> : public luaMethodBinding { public: int call(lua_State *L) { @@ -1118,7 +1176,7 @@ class constructorBindingT<tObj, t0, t1, t2, void, void> : public luaMethodBindin }; template <typename tObj, typename t0, typename t1, typename t2, typename t3> -class constructorBindingT<tObj, t0, t1, t2, t3, void> : public luaMethodBinding { +class constructorBindingT<tObj, t0, t1, t2, t3, void, void> : public luaMethodBinding { public: int call(lua_State *L) { @@ -1133,6 +1191,23 @@ class constructorBindingT<tObj, t0, t1, t2, t3, void> : public luaMethodBinding } }; +template <typename tObj, typename t0, typename t1, typename t2, typename t3, typename t4> +class constructorBindingT<tObj, t0, t1, t2, t3, t4, void> : public luaMethodBinding { + public: + int call(lua_State *L) + { + lua_remove(L, 1); + (luaStack<tObj*>::push(L, new tObj(luaStack<t0>::get(L, 1), luaStack<t1>::get(L, 2), + luaStack<t2>::get(L, 3), luaStack<t3>::get(L, 4), + luaStack<t4>::get(L, 5)))); + return 1; + } + void getArgTypeNames(std::vector<std::string> &names) + { + argTypeNames<void (tObj::*)(t0, t1, t2, t3,t4)>::get(names); + } +}; + template <class t> class destructorBindingT : public luaMethodBinding { public: @@ -1273,6 +1348,14 @@ class classBinding { addMethodLua(n,mb); return mb; } + template <typename tObj, typename t0, typename t1, typename t2, typename t3, + typename t4, typename t5> + methodBinding *setConstructor() + { + luaMethodBinding *constructorLua = new constructorBindingT<tObj,t0,t1,t2,t3,t4,t5>; + setConstructorLuaMethod(constructorLua); + return constructorLua; + } template <typename tObj, typename t0, typename t1, typename t2, typename t3, typename t4> methodBinding *setConstructor() diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp index a98a9ede1eac4129d7504bcaba7f69e1f2ea02f9..fc3c79b867200d842a40e59f5539b74455098511 100644 --- a/Geo/GEdge.cpp +++ b/Geo/GEdge.cpp @@ -91,6 +91,10 @@ void GEdge::addFace(GFace *e) l_faces.push_back(e); } +void GEdge::addLine (MLine *line){ + lines.push_back(line); +} + void GEdge::delFace(GFace *e) { l_faces.erase(std::find(l_faces.begin(), l_faces.end(), e)); @@ -369,4 +373,7 @@ void GEdge::registerBindings(binding *b) mb->setDescription("get the begin-vertex of the edge"); mb = cb->addMethod("getEndVertex", &GEdge::getEndVertex); mb->setDescription("get the end-vertex of the edge"); + mb = cb->addMethod("addLine", &GEdge::addLine); + mb->setDescription("insert a line mesh element"); + mb->setArgNames("line", NULL); } diff --git a/Geo/GEdge.h b/Geo/GEdge.h index f1acad2c813922ff61a99ece226844d402723be7..7fe10d796e0bf2374d5c76a16a3608486d421c3c 100644 --- a/Geo/GEdge.h +++ b/Geo/GEdge.h @@ -197,6 +197,8 @@ class GEdge : public GEntity { std::vector<MLine*> lines; + void addLine(MLine *line); + static void registerBindings(binding *b); }; diff --git a/Geo/GEntity.cpp b/Geo/GEntity.cpp index 387fdc3736da21f9eb8f0784d5a80f01ca9dc762..d7f79ea82299f5a6469b53ef75ca96a1f41694be 100644 --- a/Geo/GEntity.cpp +++ b/Geo/GEntity.cpp @@ -88,6 +88,9 @@ void GEntity::registerBindings(binding *b) mb = cb->addMethod("getMeshVertex",&GEntity::getMeshVertex); mb->setDescription("get the mesh vertex at the given index"); mb->setArgNames("index",NULL); + mb = cb->addMethod("addMeshVertex",&GEntity::addMeshVertex); + mb->setDescription("insert a new mesh vertex"); + mb->setArgNames("vertex",NULL); mb = cb->addMethod("model", &GEntity::model); mb->setDescription("returns the geometric model the entity belongs to."); mb = cb->addMethod("cast2Vertex", &GEntity::cast2Vertex); @@ -98,4 +101,7 @@ void GEntity::registerBindings(binding *b) mb->setDescription("do a dynamic cast of the GEntity to a GFace (0 if wrong cast)."); mb = cb->addMethod("cast2Region", &GEntity::cast2Region); mb->setDescription("do a dynamic cast of the GEntity to a GRegion (0 if wrong cast)."); + mb = cb->addMethod("tag", &GEntity::tag); + mb->setDescription("return the tag of this entity."); + } diff --git a/Geo/GEntity.h b/Geo/GEntity.h index 1ba28e5509989cf675ac2685a4ad785568e81f2c..f446cf632292dfe7ca9b2ddfc8606732e7644060 100644 --- a/Geo/GEntity.h +++ b/Geo/GEntity.h @@ -278,6 +278,9 @@ class GEntity { // get the mesh vertex at the given index MVertex *getMeshVertex(unsigned int index) { return mesh_vertices[index]; } + //add a MeshVertex + void addMeshVertex(MVertex *v) { mesh_vertices.push_back(v);} + // clean downcasts GVertex *cast2Vertex(); GEdge *cast2Edge(); diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index 2236d7ef6d6624b024f45ff01bfa939c12076c0c..8271e449cc1f05b335e4b0e11f1b6f0e87b2f660 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -1177,6 +1177,15 @@ void GFace::moveToValidRange(SPoint2 &pt) const } } +void GFace::addTriangle(MTriangle *t) { + triangles.push_back(t); +} +void GFace::addQuadrangle(MQuadrangle *q) { + quadrangles.push_back(q); +} +void GFace::addPolygon(MPolygon *p) { + polygons.push_back(p); +} #include "Bindings.h" @@ -1185,8 +1194,19 @@ void GFace::registerBindings(binding *b) classBinding *cb = b->addClass<GFace>("GFace"); cb->setParentClass<GEntity>(); 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); + methodBinding *mb; + mb = cb->addMethod("lloyd", &GFace::lloyd); + mb->setDescription("do N iteration of Lloyd's algorithm using or not the infinite norm"); + mb->setArgNames("N","infiniteNorm",NULL); + mb = cb->addMethod("addTriangle", &GFace::addTriangle); + mb->setDescription("insert a triangle mesh element"); + mb->setArgNames("triangle", NULL); + mb = cb->addMethod("addQuadrangle", &GFace::addQuadrangle); + mb->setDescription("insert a quadrangle mesh element"); + mb->setArgNames("quadrangle", NULL); + mb = cb->addMethod("edges", &GFace::edges); + mb->setDescription("return the list of edges bounding this surface"); +/* mb = cb->addMethod("addPolygon", &GFace::addPolygon); + mb->setDescription("insert a polygon mesh element"); + mb->setArgNames("polygon", NULL);*/ } diff --git a/Geo/GFace.h b/Geo/GFace.h index a84ffe9a29e16220b73bd9111e2e9bf4b53fc3b7..f7044dde96f358f65636b307da5cf0bb06fb63f3 100644 --- a/Geo/GFace.h +++ b/Geo/GFace.h @@ -298,6 +298,10 @@ class GFace : public GEntity std::vector<MQuadrangle*> quadrangles; std::vector<MPolygon*> polygons; + void addTriangle(MTriangle *t); + void addQuadrangle(MQuadrangle *q); + void addPolygon(MPolygon *p); + // an array with additional vertices that are supposed to exist // in the final mesh of the model face. This can be used for // boundary layer meshes or when using Lloyd-like smoothing algorithms diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 1f04a43fce8c1f92cec1a5c8dc2309606506f72b..ecb4c7554e1e198155ad450830285dca73becd9b 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -308,6 +308,26 @@ int GModel::maxRegionNum() return MAXX; } +std::vector<GRegion*> GModel::bindingsGetRegions() +{ + return std::vector<GRegion*> (regions.begin(), regions.end()); +} + +std::vector<GFace*> GModel::bindingsGetFaces() +{ + return std::vector<GFace*> (faces.begin(), faces.end()); +} + +std::vector<GEdge*> GModel::bindingsGetEdges() +{ + return std::vector<GEdge*> (edges.begin(), edges.end()); +} + +std::vector<GVertex*> GModel::bindingsGetVertices() +{ + return std::vector<GVertex*> (vertices.begin(), vertices.end()); +} + GRegion *GModel::getRegionByTag(int n) const { GEntity tmp((GModel*)this, n); @@ -1956,6 +1976,15 @@ void GModel::registerBindings(binding *b) cm->setDescription("access a geometrical region by tag"); cm->setArgNames("tag", NULL); + cm = cb->addMethod("getRegions", &GModel::bindingsGetRegions); + cm->setDescription("return a vector of the regions"); + cm = cb->addMethod("getFaces", &GModel::bindingsGetFaces); + cm->setDescription("return a vector of the faces"); + cm = cb->addMethod("getEdges", &GModel::bindingsGetEdges); + cm->setDescription("return a vector of the edges"); + cm = cb->addMethod("getVertices", &GModel::bindingsGetVertices); + cm->setDescription("return a vector of the vertices"); + cm = cb->addMethod("addVertex", &GModel::addVertex); cm->setDescription("create a new vertex at position (x, y, z), with target " "mesh size lc"); diff --git a/Geo/GModel.h b/Geo/GModel.h index 394776770d3e365313199d20cbd47aab1a0fb46d..5327353a1e02314df9896064b62c14453c2c3cc9 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -208,6 +208,12 @@ class GModel GEdge *getEdgeByTag(int n) const; GVertex *getVertexByTag(int n) const; + // for lua bindings, temporary solution while iterator are not binded + std::vector<GRegion*> bindingsGetRegions(); + std::vector<GFace*> bindingsGetFaces(); + std::vector<GEdge*> bindingsGetEdges(); + std::vector<GVertex*> bindingsGetVertices(); + // add/remove an entity in the model void add(GRegion *r) { regions.insert(r); } void add(GFace *f) { faces.insert(f); } diff --git a/Geo/GRegion.cpp b/Geo/GRegion.cpp index fa0c64346bb3012cec75cc9a0d3971673a4ccb44..cac22c523c25bd645df0934f36b62b98cc194df0 100644 --- a/Geo/GRegion.cpp +++ b/Geo/GRegion.cpp @@ -286,9 +286,22 @@ void GRegion::replaceFaces (std::list<GFace*> &new_faces) l_dirs = newdirs; } +void GRegion::addPrism(MPrism *p) { + prisms.push_back(p); +} + void GRegion::registerBindings(binding *b) { classBinding *cb = b->addClass<GRegion>("GRegion"); cb->setDescription("A GRegion is a geometrical 3D entity"); cb->setParentClass<GEntity>(); + methodBinding *cm = cb->setConstructor<GRegion,GModel*,int>(); + cm->setDescription("create a new GRegion"); + cm->setArgNames("model","tag",NULL); + cm = cb->addMethod("set",&GRegion::set); + cm->setDescription("set the faces that bound this region"); + cm->setArgNames("faces",NULL); + cm = cb->addMethod("addPrism", &GRegion::addPrism); + cm->setDescription("insert a prism mesh element"); + cm->setArgNames("prism", NULL); } diff --git a/Geo/GRegion.h b/Geo/GRegion.h index c72e768ae9a2f5093b384a117a3ff3118b915156..705361afee2a9989c5c5614993b4374f9436fc58 100644 --- a/Geo/GRegion.h +++ b/Geo/GRegion.h @@ -47,7 +47,7 @@ class GRegion : public GEntity { // get/set faces that bound the region virtual std::list<GFace*> faces() const{ return l_faces; } virtual std::list<int> faceOrientations() const{ return l_dirs; } - void set(std::list<GFace*> &f) { l_faces = f; } + inline void set(const std::list<GFace*> f) { l_faces = f; } // edges that bound the region virtual std::list<GEdge*> edges() const; @@ -102,6 +102,8 @@ class GRegion : public GEntity { std::vector<MPyramid*> pyramids; std::vector<MPolyhedron*> polyhedra; + void addPrism(MPrism *p); + // replace edges (gor gluing) void replaceFaces (std::list<GFace*> &); diff --git a/Geo/MLine.cpp b/Geo/MLine.cpp index eb79c54a6c2dc9babbd02c2b998af1e3b2a85415..a8fcf4d93092e826a07aa89af0041e1b0180a1a2 100644 --- a/Geo/MLine.cpp +++ b/Geo/MLine.cpp @@ -39,3 +39,17 @@ double MLine::getInnerRadius() { return _v[0]->distance(_v[1]); } + +#include "Bindings.h" + +void MLine::registerBindings(binding *b) +{ + classBinding *cb = b->addClass<MLine>("MLine"); + cb->setDescription("A line mesh element."); + + methodBinding *cm; + cm = cb->setConstructor<MLine,MVertex*,MVertex*>(); + cm->setArgNames("v0","v1", NULL); + cm->setDescription("Create a new line mesh element between v0 and v1."); + cb->setParentClass<MElement>(); +} diff --git a/Geo/MLine.h b/Geo/MLine.h index de78ae3daea133e0b000dd15610d260fd05dfedf..ff6de0647c7e7de2ab77d13819bc989986cb1748 100644 --- a/Geo/MLine.h +++ b/Geo/MLine.h @@ -77,6 +77,7 @@ class MLine : public MElement { return true; } virtual void getIntegrationPoints(int pOrder, int *npts, IntPt **pts); + static void registerBindings(binding *b); }; /* @@ -137,6 +138,7 @@ class MLine3 : public MLine { * 0---2---...-(N-1)-1 * */ +class binding; class MLineN : public MLine { protected: std::vector<MVertex *> _vs; diff --git a/Geo/MPrism.cpp b/Geo/MPrism.cpp index 36a2bf749ae12ba104ee664db35a1790f31dce07..5627aeeb1060cc4fce1f51f3a5092463598cd891 100644 --- a/Geo/MPrism.cpp +++ b/Geo/MPrism.cpp @@ -125,3 +125,16 @@ void MPrism::getFaceInfo(const MFace &face, int &ithFace, int &sign, int &rot) c } Msg::Error("Could not get face information for prism %d", getNum()); } +#include "Bindings.h" + +void MPrism::registerBindings(binding *b) +{ + classBinding *cb = b->addClass<MPrism>("MPrism"); + cb->setDescription("A mesh first-order prism."); + methodBinding *cm; + cm = cb->setConstructor<MPrism,MVertex*,MVertex*,MVertex*,MVertex*, MVertex*, MVertex*>(); + cm->setArgNames("v0", "v1", "v2", "v3","v4","v5", NULL); + cm->setDescription("Create a new prism with top triangle (v0,v1,v2) and bottom one (v3,v4,v5)."); + cb->setParentClass<MElement>(); +} + diff --git a/Geo/MPrism.h b/Geo/MPrism.h index 1efd463a12dc71f453883f202d1b48e663543aef..13477e419a12a1a8e29db811853525d818b59b5e 100644 --- a/Geo/MPrism.h +++ b/Geo/MPrism.h @@ -8,6 +8,7 @@ #include "MElement.h" +class binding; /* * MPrism * @@ -198,6 +199,8 @@ class MPrism : public MElement { }; return f[face][vert]; } + public: + static void registerBindings(binding *b); }; /* diff --git a/Geo/MQuadrangle.cpp b/Geo/MQuadrangle.cpp index 098e061b41ee72a5a046b441d785a5e5183d37b6..35dec5246e36dd7884aa94d253ea48ed887c2b61 100644 --- a/Geo/MQuadrangle.cpp +++ b/Geo/MQuadrangle.cpp @@ -272,3 +272,15 @@ double MQuadrangle::getInnerRadius() } return R; } +#include "Bindings.h" + +void MQuadrangle::registerBindings(binding *b) +{ + classBinding *cb = b->addClass<MQuadrangle>("MQuadrangle"); + cb->setDescription("A mesh first-order quadrangle."); + methodBinding *cm; + cm = cb->setConstructor<MQuadrangle,MVertex*,MVertex*,MVertex*,MVertex*>(); + cm->setArgNames("v0", "v1", "v2", "v3", NULL); + cm->setDescription("Create a new quadrangle with vertices (v0,v1,v2,v3)."); + cb->setParentClass<MElement>(); +} diff --git a/Geo/MQuadrangle.h b/Geo/MQuadrangle.h index 584ee6aa3d9385ce00786af2dddb001cb4d1e81d..2f6abe5e8f7d932d9330aa97fa5d528ed28a0ea6 100644 --- a/Geo/MQuadrangle.h +++ b/Geo/MQuadrangle.h @@ -23,6 +23,7 @@ * 0-----------1 * */ +class binding; class MQuadrangle : public MElement { protected: MVertex *_v[4]; @@ -146,6 +147,9 @@ class MQuadrangle : public MElement { }; return e[edge][vert]; } + + public: + static void registerBindings(binding *b); }; /* diff --git a/Geo/MTriangle.cpp b/Geo/MTriangle.cpp index 3365ed4250fa82c9f62bdc6fff1e85238ae27be8..fc65008a33f82f99f39dca1fc0a58551cc391302 100644 --- a/Geo/MTriangle.cpp +++ b/Geo/MTriangle.cpp @@ -232,4 +232,16 @@ void MTriangle::getIntegrationPoints(int pOrder, int *npts, IntPt **pts) *npts = getNGQTPts(pOrder); *pts = getGQTPts(pOrder); } +#include "Bindings.h" + +void MTriangle::registerBindings(binding *b) +{ + classBinding *cb = b->addClass<MTriangle>("MTriangle"); + cb->setDescription("A mesh first-order triangle."); + methodBinding *cm; + cm = cb->setConstructor<MTriangle,MVertex*,MVertex*,MVertex*>(); + cm->setArgNames("v0", "v1", "v2", NULL); + cm->setDescription("Create a new triangle with vertices (v0,v1,v2)."); + cb->setParentClass<MElement>(); +} diff --git a/Geo/MTriangle.h b/Geo/MTriangle.h index 08b124c9a9572e00c52cd79675ebf5bbf0325c92..c1fe493607f101c16a316a1312a7744dab4f3b14 100644 --- a/Geo/MTriangle.h +++ b/Geo/MTriangle.h @@ -38,7 +38,7 @@ class MTriangle : public MElement { v[2] = _v[2]; } public : - MTriangle(MVertex *v0, MVertex *v1, MVertex *v2, int num=0, int part=0) + MTriangle(MVertex *v0, MVertex *v1, MVertex *v2, int num=0, int part=0) : MElement(num, part) { _v[0] = v0; _v[1] = v1; _v[2] = v2; @@ -144,6 +144,8 @@ class MTriangle : public MElement { }; return e[edge][vert]; } + public: + static void registerBindings(binding *b); }; /* diff --git a/Geo/MVertex.cpp b/Geo/MVertex.cpp index 92c787de6d3ce8af1a3568bcd711dbffb714986c..bf523e196718e56bcb4994f8d33556197c75ba1f 100644 --- a/Geo/MVertex.cpp +++ b/Geo/MVertex.cpp @@ -420,4 +420,6 @@ void MVertex::registerBindings(binding *b) cm = cb->setConstructor<MVertex,double,double,double>(); cm->setArgNames("x", "y", "z", NULL); cm->setDescription("Create a new mesh vertex at (x,y,z)."); + cm = cb->addMethod("getNum", &MVertex::getNum); + cm->setDescription("return the invariant vertex id"); }