Skip to content
Snippets Groups Projects
Commit 07dfc7c0 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

new command "BoundingBox GeoEntity { tag }" to retrieve the bbox of an entity

parent 56c18b6d
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
......@@ -496,7 +496,7 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 164 "Gmsh.y"
#line 165 "Gmsh.y"
{
char *c;
int i;
......
......@@ -129,6 +129,7 @@ void getAllPhysicalTags(int dim, List_T *in);
void getElementaryTagsForPhysicalGroups(int dim, List_T *in, List_T *out);
void getElementaryTagsInBoundingBox(int dim, double x1, double y1, double z1,
double x2, double y2, double z2, List_T *out);
void getBoundingBox(int dim, int tag, List_T *out);
void setVisibility(int dim, int visible, bool recursive);
void setVisibility(const std::vector<std::pair<int, int> > &dimTags, int visible,
bool recursive);
......@@ -5361,6 +5362,11 @@ FExpr_Multi :
$$ = List_Create(10, 10, sizeof(double));
getElementaryTagsInBoundingBox($1, $5, $7, $9, $11, $13, $15, $$);
}
| tBoundingBox GeoEntity '{' FExpr '}'
{
$$ = List_Create(10, 10, sizeof(double));
getBoundingBox($2, (int)$4, $$);
}
| Transform
{
$$ = List_Create(List_Nbr($1), 1, sizeof(double));
......@@ -6651,6 +6657,25 @@ void getElementaryTagsInBoundingBox(int dim, double x1, double y1, double z1,
}
}
void getBoundingBox(int dim, int tag, List_T *out)
{
if(GModel::current()->getOCCInternals() &&
GModel::current()->getOCCInternals()->getChanged())
GModel::current()->getOCCInternals()->synchronize(GModel::current());
if(GModel::current()->getGEOInternals()->getChanged())
GModel::current()->getGEOInternals()->synchronize(GModel::current());
GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
SBoundingBox3d box;
if(ge) box = ge->bounds();
if(!box.empty()){
double b[6] = {box.min().x(), box.min().y(), box.min().z(),
box.max().x(), box.max().y(), box.max().z()};
for(int i = 0; i < 6; i++)
List_Add(out, &b[i]);
}
}
void setVisibility(int dim, int visible, bool recursive)
{
if(GModel::current()->getOCCInternals() &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment