diff --git a/Common/LuaBindings.cpp b/Common/LuaBindings.cpp index 73c2a99b6727a1603dbaee8a09164e7b43b21adc..8ab9b1ec872a1b7413d33610144b33ae6b499bd0 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 e6e5323f6cf0c1080aecfc0b461999c42d3ee083..044b4fd80cc92eff6a259e2d70387d67b70a6204 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 11a8a33eb8a134c03e7e4c512885275e3bf4f9f8..7d04e8e735c584105dec29f519272e0662a558f9 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 f27407a8c3fcb59b18e7952e2a87397edeb1c80e..613a2fc982d947d755443fae26103cb5e2365553 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 7ed9ad984f85757e5223d2e320d139e66d5154ae..6a3258f54c2da6e729bfb9e3129e96be6faee8db 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 8da7e54826a107d086f3f46b67dab730ebcf3dc4..3030182672711f3645a3c5c2f357449be4377593 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 2df5830f5df721f8939e3da9319e93237d7b9668..9befada9bf4b939ebb802b0524783113464458bf 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 9aa7e754f820a77663076a9a093ca136a321ff76..eff8f377e6a5b5c255a3855bf0ec3d04d4d95af0 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