From eb34e0a677c6c05358b405b278e702f83ec2dcf4 Mon Sep 17 00:00:00 2001 From: Emilie Marchandise <emilie.marchandise@uclouvain.be> Date: Wed, 10 Nov 2010 16:36:18 +0000 Subject: [PATCH] Added some bindings for lua function liftAndDrag for NS --- Common/LuaBindings.cpp | 2 ++ Geo/CMakeLists.txt | 2 +- Geo/GEdge.cpp | 9 +++++++++ Geo/GEdge.h | 10 ++++++++++ Geo/GEntity.cpp | 1 + Geo/GModel.cpp | 21 +++++++++++++++++++++ Geo/GModel.h | 6 ++++++ Geo/GPoint.h | 3 +++ 8 files changed, 53 insertions(+), 1 deletion(-) diff --git a/Common/LuaBindings.cpp b/Common/LuaBindings.cpp index 73c2a99b67..8ab9b1ec87 100644 --- a/Common/LuaBindings.cpp +++ b/Common/LuaBindings.cpp @@ -26,6 +26,7 @@ #include "luaFunction.h" #include "function.h" #include "GModel.h" +#include "GPoint.h" #include "Bindings.h" #include "GmshMessage.h" #include "Options.h" @@ -405,6 +406,7 @@ binding::binding() GFace::registerBindings(this); GRegion::registerBindings(this); GModel::registerBindings(this); + GPoint::registerBindings(this); MElement::registerBindings(this); MVertex::registerBindings(this); MTriangle::registerBindings(this); diff --git a/Geo/CMakeLists.txt b/Geo/CMakeLists.txt index e6e5323f6c..044b4fd80c 100644 --- a/Geo/CMakeLists.txt +++ b/Geo/CMakeLists.txt @@ -5,7 +5,7 @@ set(SRC GEntity.cpp STensor3.cpp - GVertex.cpp GEdge.cpp GFace.cpp GRegion.cpp + GVertex.cpp GEdge.cpp GFace.cpp GRegion.cpp GPoint.cpp GEdgeLoop.cpp GEdgeCompound.cpp GFaceCompound.cpp GRegionCompound.cpp gmshVertex.cpp gmshEdge.cpp gmshFace.cpp gmshRegion.cpp gmshSurface.cpp OCCVertex.cpp OCCEdge.cpp OCCFace.cpp OCCRegion.cpp diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp index 11a8a33eb8..7d04e8e735 100644 --- a/Geo/GEdge.cpp +++ b/Geo/GEdge.cpp @@ -389,4 +389,13 @@ void GEdge::registerBindings(binding *b) mb = cb->addMethod("addLine", &GEdge::addLine); mb->setDescription("insert a line mesh element"); mb->setArgNames("line", NULL); + + mb = cb->addMethod("getLowBound", &GEdge::getLowBound); + mb->setDescription("get the lower bound of the parametrization of the Edge"); + mb = cb->addMethod("getHighBound", &GEdge::getHighBound); + mb->setDescription("get the lower bound of the parametrization of the Edge"); + + //mb = cb->addMethod("point", &GEdge::point); + //mb->setDescription("returns the GPoint for a given double parameter"); + //mb->setArgNames("double", NULL); } diff --git a/Geo/GEdge.h b/Geo/GEdge.h index f27407a8c3..613a2fc982 100644 --- a/Geo/GEdge.h +++ b/Geo/GEdge.h @@ -178,6 +178,16 @@ class GEdge : public GEntity { // gluing void replaceEndingPoints(GVertex *, GVertex *); + //get bounds + inline double getLowBound() const { + Range<double> bounds = parBounds(0); + return bounds.low(); + } + inline double getHighBound() const { + Range<double> bounds = parBounds(0); + return bounds.high(); + } + struct { char Method; double coeffTransfinite; diff --git a/Geo/GEntity.cpp b/Geo/GEntity.cpp index 7ed9ad984f..6a3258f54c 100644 --- a/Geo/GEntity.cpp +++ b/Geo/GEntity.cpp @@ -107,6 +107,7 @@ void GEntity::registerBindings(binding *b) mb = cb->addMethod("addPhysicalEntity", &GEntity::addPhysicalEntity); mb->setArgNames("physicalGroupId",NULL); mb->setDescription("add this element to a physical group."); + } diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 8da7e54826..3030182672 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -247,6 +247,8 @@ GEdge *GModel::getEdgeByTag(int n) const return 0; } + + GVertex *GModel::getVertexByTag(int n) const { GEntity tmp((GModel*)this, n); @@ -257,6 +259,21 @@ GVertex *GModel::getVertexByTag(int n) const return 0; } +//we should have dynamic cast to GEdge* instead of returning GEntity* +std::vector<GEntity*> GModel::getEdgesByStringTag(const std::string tag) +{ + std::vector<GEntity*> allEdges; + std::map<int, std::vector<GEntity*> > physicalGroups[4]; + this->getPhysicalGroups(physicalGroups); + allEdges = physicalGroups[1][this->getPhysicalNumber(1,tag)]; + +} +GEdge *GModel::getFirstEdgeByStringTag(const std::string tag) +{ + std::vector<GEntity*> allEdges = this->getEdgesByStringTag(tag); + return (GEdge*)allEdges[0]; +} + void GModel::remove(GRegion *r) { riter it = std::find(firstRegion(), lastRegion(), r); @@ -2700,4 +2717,8 @@ void GModel::registerBindings(binding *b) cm->setDescription("Assigns partition tags to boundary elements. Should be called " "only after the partitions have been assigned"); cm->setArgNames("createGhostCells",NULL); + + cm = cb->addMethod("getFirstEdgeByStringTag", &GModel::getFirstEdgeByStringTag); + cm->setDescription("return the first edge of the physical line with given tag."); + cm->setArgNames("string tag",NULL); } diff --git a/Geo/GModel.h b/Geo/GModel.h index 2df5830f5d..9befada9bf 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -209,6 +209,12 @@ class GModel GEdge *getEdgeByTag(int n) const; GVertex *getVertexByTag(int n) const; + //Emi- we should return vector of GEdges instead + std::vector<GEntity*> getEdgesByStringTag(const std::string tag) ; + //Emi - I do not know how to bind std::vector in lua so I return only first edge + //and used Compound Line to have a unique GEdge + GEdge *getFirstEdgeByStringTag(const std::string tag) ; + // for lua bindings, temporary solution while iterator are not binded std::vector<GRegion*> bindingsGetRegions(); std::vector<GFace*> bindingsGetFaces(); diff --git a/Geo/GPoint.h b/Geo/GPoint.h index 9aa7e754f8..eff8f377e6 100644 --- a/Geo/GPoint.h +++ b/Geo/GPoint.h @@ -9,6 +9,7 @@ #include <math.h> class GEntity; +class binding; class GPoint { @@ -54,6 +55,8 @@ class GPoint } bool succeeded() const{ return success; } bool setNoSuccess(){ success = false; return success; } + + static void registerBindings(binding *b); }; #endif -- GitLab