From 36e437d5b4e5da22917921fe2117d6aacccb3860 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sun, 2 Apr 2017 22:59:30 +0200 Subject: [PATCH] allow explit/implicit tag assignement in GEO_Internals (same as in OCC_Internals). Implicit is now only for tag < 0 (and not tag <= 0): this is for backward compatibility, because quite a few models define entities "0". --- Geo/GModelIO_GEO.cpp | 201 +++++++++++++++++++++++-------------------- Geo/GModelIO_GEO.h | 46 +++++----- Geo/GModelIO_OCC.cpp | 80 ++++++++--------- 3 files changed, 172 insertions(+), 155 deletions(-) diff --git a/Geo/GModelIO_GEO.cpp b/Geo/GModelIO_GEO.cpp index 78967d1961..bc05226d18 100644 --- a/Geo/GModelIO_GEO.cpp +++ b/Geo/GModelIO_GEO.cpp @@ -99,51 +99,54 @@ int GEO_Internals::getMaxTag(int dim) const } } -bool GEO_Internals::addVertex(int num, double x, double y, double z, double lc) +bool GEO_Internals::addVertex(int &tag, double x, double y, double z, double lc) { - if(FindPoint(num)){ - Msg::Error("GEO vertex with tag %d already exists", num); + if(tag >= 0 && FindPoint(tag)){ + Msg::Error("GEO vertex with tag %d already exists", tag); return false; } - Vertex *v = CreateVertex(num, x, y, z, lc, 1.0); + if(tag < 0) tag = getMaxTag(0) + 1; + Vertex *v = CreateVertex(tag, x, y, z, lc, 1.0); Tree_Add(Points, &v); _changed = true; return true; } -bool GEO_Internals::addVertex(int num, double x, double y, gmshSurface *surface, +bool GEO_Internals::addVertex(int &tag, double x, double y, gmshSurface *surface, double lc) { - if(FindPoint(num)){ - Msg::Error("GEO vertex with tag %d already exists", num); + if(tag >= 0 && FindPoint(tag)){ + Msg::Error("GEO vertex with tag %d already exists", tag); return false; } - Vertex *v = CreateVertex(num, x, y, surface, lc); + if(tag < 0) tag = getMaxTag(0) + 1; + Vertex *v = CreateVertex(tag, x, y, surface, lc); Tree_Add(Points, &v); _changed = true; return true; } -bool GEO_Internals::addLine(int num, int startTag, int endTag) +bool GEO_Internals::addLine(int &tag, int startTag, int endTag) { std::vector<int> points; points.push_back(startTag); points.push_back(endTag); - return addLine(num, points); + return addLine(tag, points); } -bool GEO_Internals::addLine(int num, const std::vector<int> &vertexTags) +bool GEO_Internals::addLine(int &tag, const std::vector<int> &vertexTags) { - if(FindCurve(num)){ - Msg::Error("GEO edge with tag %d already exists", num); + if(tag >= 0 && FindCurve(tag)){ + Msg::Error("GEO edge with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(1) + 1; List_T *tmp = List_Create(2, 2, sizeof(int)); for(unsigned int i = 0; i < vertexTags.size(); i++){ int t = vertexTags[i]; List_Add(tmp, &t); } - Curve *c = CreateCurve(num, MSH_SEGM_LINE, 1, tmp, NULL, -1, -1, 0., 1.); + Curve *c = CreateCurve(tag, MSH_SEGM_LINE, 1, tmp, NULL, -1, -1, 0., 1.); Tree_Add(Curves, &c); CreateReversedCurve(c); List_Delete(tmp); @@ -151,18 +154,19 @@ bool GEO_Internals::addLine(int num, const std::vector<int> &vertexTags) return true; } -bool GEO_Internals::addCircleArc(int num, int startTag, int centerTag, int endTag, +bool GEO_Internals::addCircleArc(int &tag, int startTag, int centerTag, int endTag, double nx, double ny, double nz) { - if(FindCurve(num)){ - Msg::Error("GEO edge with tag %d already exists", num); + if(tag >= 0 && FindCurve(tag)){ + Msg::Error("GEO edge with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(1) + 1; List_T *tmp = List_Create(3, 2, sizeof(int)); List_Add(tmp, &startTag); List_Add(tmp, ¢erTag); List_Add(tmp, &endTag); - Curve *c = CreateCurve(num, MSH_SEGM_CIRC, 2, tmp, NULL, -1, -1, 0., 1.); + Curve *c = CreateCurve(tag, MSH_SEGM_CIRC, 2, tmp, NULL, -1, -1, 0., 1.); if(nx || ny || nz){ c->Circle.n[0] = nx; c->Circle.n[1] = ny; @@ -182,19 +186,20 @@ bool GEO_Internals::addCircleArc(int num, int startTag, int centerTag, int endTa return true; } -bool GEO_Internals::addEllipseArc(int num, int startTag, int centerTag, int majorTag, +bool GEO_Internals::addEllipseArc(int &tag, int startTag, int centerTag, int majorTag, int endTag, double nx, double ny, double nz) { - if(FindCurve(num)){ - Msg::Error("GEO edge with tag %d already exists", num); + if(tag >= 0 && FindCurve(tag)){ + Msg::Error("GEO edge with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(1) + 1; List_T *tmp = List_Create(3, 2, sizeof(int)); List_Add(tmp, &startTag); List_Add(tmp, ¢erTag); List_Add(tmp, &majorTag); List_Add(tmp, &endTag); - Curve *c = CreateCurve(num, MSH_SEGM_ELLI, 2, tmp, NULL, -1, -1, 0., 1.); + Curve *c = CreateCurve(tag, MSH_SEGM_ELLI, 2, tmp, NULL, -1, -1, 0., 1.); if(nx || ny || nz){ c->Circle.n[0] = nx; c->Circle.n[1] = ny; @@ -214,18 +219,19 @@ bool GEO_Internals::addEllipseArc(int num, int startTag, int centerTag, int majo return true; } -bool GEO_Internals::addSpline(int num, const std::vector<int> &vertexTags) +bool GEO_Internals::addSpline(int &tag, const std::vector<int> &vertexTags) { - if(FindCurve(num)){ - Msg::Error("GEO edge with tag %d already exists", num); + if(tag >= 0 && FindCurve(tag)){ + Msg::Error("GEO edge with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(1) + 1; List_T *tmp = List_Create(2, 2, sizeof(int)); for(unsigned int i = 0; i < vertexTags.size(); i++){ int t = vertexTags[i]; List_Add(tmp, &t); } - Curve *c = CreateCurve(num, MSH_SEGM_SPLN, 3, tmp, NULL, -1, -1, 0., 1.); + Curve *c = CreateCurve(tag, MSH_SEGM_SPLN, 3, tmp, NULL, -1, -1, 0., 1.); Tree_Add(Curves, &c); CreateReversedCurve(c); List_Delete(tmp); @@ -233,18 +239,19 @@ bool GEO_Internals::addSpline(int num, const std::vector<int> &vertexTags) return true; } -bool GEO_Internals::addBSpline(int num, const std::vector<int> &vertexTags) +bool GEO_Internals::addBSpline(int &tag, const std::vector<int> &vertexTags) { - if(FindCurve(num)){ - Msg::Error("GEO edge with tag %d already exists", num); + if(tag >= 0 && FindCurve(tag)){ + Msg::Error("GEO edge with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(1) + 1; List_T *tmp = List_Create(2, 2, sizeof(int)); for(unsigned int i = 0; i < vertexTags.size(); i++){ int t = vertexTags[i]; List_Add(tmp, &t); } - Curve *c = CreateCurve(num, MSH_SEGM_BSPLN, 2, tmp, NULL, -1, -1, 0., 1.); + Curve *c = CreateCurve(tag, MSH_SEGM_BSPLN, 2, tmp, NULL, -1, -1, 0., 1.); Tree_Add(Curves, &c); CreateReversedCurve(c); List_Delete(tmp); @@ -252,12 +259,13 @@ bool GEO_Internals::addBSpline(int num, const std::vector<int> &vertexTags) return true; } -bool GEO_Internals::addBezier(int num, const std::vector<int> &vertexTags) +bool GEO_Internals::addBezier(int &tag, const std::vector<int> &vertexTags) { - if(FindCurve(num)){ - Msg::Error("GEO edge with tag %d already exists", num); + if(tag >= 0 && FindCurve(tag)){ + Msg::Error("GEO edge with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(1) + 1; if(vertexTags.size() < 4){ Msg::Error("Bezier curve requires at least 4 control points"); return false; @@ -267,7 +275,7 @@ bool GEO_Internals::addBezier(int num, const std::vector<int> &vertexTags) int t = vertexTags[i]; List_Add(tmp, &t); } - Curve *c = CreateCurve(num, MSH_SEGM_BEZIER, 2, tmp, NULL, -1, -1, 0., 1.); + Curve *c = CreateCurve(tag, MSH_SEGM_BEZIER, 2, tmp, NULL, -1, -1, 0., 1.); Tree_Add(Curves, &c); CreateReversedCurve(c); List_Delete(tmp); @@ -275,13 +283,14 @@ bool GEO_Internals::addBezier(int num, const std::vector<int> &vertexTags) return true; } -bool GEO_Internals::addNurbs(int num, const std::vector<int> &vertexTags, +bool GEO_Internals::addNurbs(int &tag, const std::vector<int> &vertexTags, const std::vector<double> &knots) { - if(FindCurve(num)){ - Msg::Error("GEO edge with tag %d already exists", num); + if(tag >= 0 && FindCurve(tag)){ + Msg::Error("GEO edge with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(1) + 1; int order = knots.size() - vertexTags.size() - 1; List_T *tmp = List_Create(2, 2, sizeof(int)); for(unsigned int i = 0; i < vertexTags.size(); i++){ @@ -293,7 +302,7 @@ bool GEO_Internals::addNurbs(int num, const std::vector<int> &vertexTags, double d = knots[i]; List_Add(knotsList, &d); } - Curve *c = CreateCurve(num, MSH_SEGM_NURBS, order, tmp, knotsList, -1, -1, 0., 1.); + Curve *c = CreateCurve(tag, MSH_SEGM_NURBS, order, tmp, knotsList, -1, -1, 0., 1.); Tree_Add(Curves, &c); CreateReversedCurve(c); List_Delete(tmp); @@ -301,14 +310,14 @@ bool GEO_Internals::addNurbs(int num, const std::vector<int> &vertexTags, return true; } -bool GEO_Internals::addCompoundLine(int num, const std::vector<int> &edgeTags) +bool GEO_Internals::addCompoundLine(int &tag, const std::vector<int> &edgeTags) { - if(FindCurve(num)){ - Msg::Error("GEO edge with tag %d already exists", num); + if(tag >= 0 && FindCurve(tag)){ + Msg::Error("GEO edge with tag %d already exists", tag); return false; } - - Curve *c = CreateCurve(num, MSH_SEGM_COMPOUND, 1, NULL, NULL, -1, -1, 0., 1.); + if(tag < 0) tag = getMaxTag(1) + 1; + Curve *c = CreateCurve(tag, MSH_SEGM_COMPOUND, 1, NULL, NULL, -1, -1, 0., 1.); c->compound = edgeTags; EndCurve(c); Tree_Add(Curves, &c); @@ -317,31 +326,33 @@ bool GEO_Internals::addCompoundLine(int num, const std::vector<int> &edgeTags) return true; } -bool GEO_Internals::addLineLoop(int num, const std::vector<int> &edgeTags) +bool GEO_Internals::addLineLoop(int &tag, const std::vector<int> &edgeTags) { - if(FindEdgeLoop(num)){ - Msg::Error("GEO line loop with tag %d already exists", num); + if(tag >= 0 && FindEdgeLoop(tag)){ + Msg::Error("GEO line loop with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(-1) + 1; List_T *tmp = List_Create(2, 2, sizeof(int)); for(unsigned int i = 0; i < edgeTags.size(); i++){ int t = edgeTags[i]; List_Add(tmp, &t); } - SortEdgesInLoop(num, tmp); - EdgeLoop *l = CreateEdgeLoop(num, tmp); + SortEdgesInLoop(tag, tmp); + EdgeLoop *l = CreateEdgeLoop(tag, tmp); Tree_Add(EdgeLoops, &l); List_Delete(tmp); _changed = true; return true; } -bool GEO_Internals::addPlaneSurface(int num, const std::vector<int> &wireTags) +bool GEO_Internals::addPlaneSurface(int &tag, const std::vector<int> &wireTags) { - if(FindSurface(num)){ - Msg::Error("GEO face with tag %d already exists", num); + if(tag >= 0 && FindSurface(tag)){ + Msg::Error("GEO face with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(2) + 1; if(wireTags.empty()){ Msg::Error("Plane surface requires at least one line loop"); return false; @@ -351,7 +362,7 @@ bool GEO_Internals::addPlaneSurface(int num, const std::vector<int> &wireTags) int t = wireTags[i]; List_Add(tmp, &t); } - Surface *s = CreateSurface(num, MSH_SURF_PLAN); + Surface *s = CreateSurface(tag, MSH_SURF_PLAN); SetSurfaceGeneratrices(s, tmp); List_Delete(tmp); EndSurface(s); @@ -360,25 +371,27 @@ bool GEO_Internals::addPlaneSurface(int num, const std::vector<int> &wireTags) return true; } -bool GEO_Internals::addDiscreteSurface(int num) +bool GEO_Internals::addDiscreteSurface(int &tag) { - if(FindSurface(num)){ - Msg::Error("GEO face with tag %d already exists", num); + if(tag >= 0 && FindSurface(tag)){ + Msg::Error("GEO face with tag %d already exists", tag); return false; } - Surface *s = CreateSurface(num, MSH_SURF_DISCRETE); + if(tag < 0) tag = getMaxTag(2) + 1; + Surface *s = CreateSurface(tag, MSH_SURF_DISCRETE); Tree_Add(Surfaces, &s); _changed = true; return true; } -bool GEO_Internals::addSurfaceFilling(int num, const std::vector<int> &wireTags, +bool GEO_Internals::addSurfaceFilling(int &tag, const std::vector<int> &wireTags, int sphereCenterTag) { - if(FindSurface(num)){ - Msg::Error("GEO face with tag %d already exists", num); + if(tag >= 0 && FindSurface(tag)){ + Msg::Error("GEO face with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(2) + 1; if(wireTags.empty()){ Msg::Error("Face requires at least one line loop"); return false; @@ -396,7 +409,7 @@ bool GEO_Internals::addSurfaceFilling(int num, const std::vector<int> &wireTags, type = MSH_SURF_TRIC; else{ Msg::Error("Wrong definition of face %d: %d borders instead of 3 or 4", - num, j); + tag, j); return false; } List_T *tmp = List_Create(2, 2, sizeof(int)); @@ -404,7 +417,7 @@ bool GEO_Internals::addSurfaceFilling(int num, const std::vector<int> &wireTags, int t = wireTags[i]; List_Add(tmp, &t); } - Surface *s = CreateSurface(num, type); + Surface *s = CreateSurface(tag, type); SetSurfaceGeneratrices(s, tmp); List_Delete(tmp); EndSurface(s); @@ -419,15 +432,16 @@ bool GEO_Internals::addSurfaceFilling(int num, const std::vector<int> &wireTags, return true; } -bool GEO_Internals::addCompoundSurface(int num, const std::vector<int> &faceTags, +bool GEO_Internals::addCompoundSurface(int &tag, const std::vector<int> &faceTags, std::vector<int> edgeTags[4]) { - if(FindSurface(num)){ - Msg::Error("GEO face with tag %d already exists", num); + if(tag >= 0 && FindSurface(tag)){ + Msg::Error("GEO face with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(2) + 1; - Surface *s = CreateSurface(num, MSH_SURF_COMPOUND); + Surface *s = CreateSurface(tag, MSH_SURF_COMPOUND); s->compound = faceTags; if(edgeTags){ for(int i = 0; i < 4; i++) @@ -439,38 +453,40 @@ bool GEO_Internals::addCompoundSurface(int num, const std::vector<int> &faceTags return true; } -bool GEO_Internals::addSurfaceLoop(int num, const std::vector<int> &faceTags) +bool GEO_Internals::addSurfaceLoop(int &tag, const std::vector<int> &faceTags) { - if(FindSurfaceLoop(num)){ - Msg::Error("GEO surface loop with tag %d already exists", num); + if(tag >= 0 && FindSurfaceLoop(tag)){ + Msg::Error("GEO surface loop with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(-2) + 1; List_T *tmp = List_Create(2, 2, sizeof(int)); for(unsigned int i = 0; i < faceTags.size(); i++){ int t = faceTags[i]; List_Add(tmp, &t); } - SurfaceLoop *l = CreateSurfaceLoop(num, tmp); + SurfaceLoop *l = CreateSurfaceLoop(tag, tmp); Tree_Add(SurfaceLoops, &l); List_Delete(tmp); _changed = true; return true; } -bool GEO_Internals::addVolume(int num, const std::vector<int> &shellTags) +bool GEO_Internals::addVolume(int &tag, const std::vector<int> &shellTags) { - if(FindVolume(num)){ - Msg::Error("GEO region with tag %d already exists", num); + if(tag >= 0 && FindVolume(tag)){ + Msg::Error("GEO region with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(3) + 1; List_T *tmp = List_Create(2, 2, sizeof(int)); for(unsigned int i = 0; i < shellTags.size(); i++){ int t = shellTags[i]; List_Add(tmp, &t); } - Volume *v = CreateVolume(num, MSH_VOLUME); + Volume *v = CreateVolume(tag, MSH_VOLUME); SetVolumeSurfaces(v, tmp); List_Delete(tmp); Tree_Add(Volumes, &v); @@ -478,14 +494,15 @@ bool GEO_Internals::addVolume(int num, const std::vector<int> &shellTags) return true; } -bool GEO_Internals::addCompoundVolume(int num, const std::vector<int> ®ionTags) +bool GEO_Internals::addCompoundVolume(int &tag, const std::vector<int> ®ionTags) { - if(FindVolume(num)){ - Msg::Error("GEO region with tag %d already exists", num); + if(tag >= 0 && FindVolume(tag)){ + Msg::Error("GEO region with tag %d already exists", tag); return false; } + if(tag < 0) tag = getMaxTag(3) + 1; - Volume *v = CreateVolume(num, MSH_VOLUME_COMPOUND); + Volume *v = CreateVolume(tag, MSH_VOLUME_COMPOUND); v->compound = regionTags; Tree_Add(Volumes, &v); _changed = true; @@ -757,7 +774,7 @@ void GEO_Internals::resetPhysicalGroups() _changed = true; } -bool GEO_Internals::modifyPhysicalGroup(int dim, int num, int op, +bool GEO_Internals::modifyPhysicalGroup(int dim, int tag, int op, const std::vector<int> &tags) { int type; @@ -770,13 +787,13 @@ bool GEO_Internals::modifyPhysicalGroup(int dim, int num, int op, default: return false; } - PhysicalGroup *p = FindPhysicalGroup(num, type); + PhysicalGroup *p = FindPhysicalGroup(tag, type); if(p && op == 0){ - Msg::Error("Physical %s %d already exists", str.c_str(), num); + Msg::Error("Physical %s %d already exists", str.c_str(), tag); return false; } else if(!p && op > 0){ - Msg::Error("Physical %s %d does not exist", str.c_str(), num); + Msg::Error("Physical %s %d does not exist", str.c_str(), tag); return false; } else if(op == 0){ @@ -785,7 +802,7 @@ bool GEO_Internals::modifyPhysicalGroup(int dim, int num, int op, int t = tags[i]; List_Add(tmp, &t); } - p = CreatePhysicalGroup(num, type, tmp); + p = CreatePhysicalGroup(tag, type, tmp); List_Delete(tmp); List_Add(PhysicalGroups, &p); } @@ -802,15 +819,15 @@ bool GEO_Internals::modifyPhysicalGroup(int dim, int num, int op, } if(!List_Nbr(p->Entities)){ switch(dim){ - case 0: DeletePhysicalPoint(num); break; - case 1: DeletePhysicalLine(num); break; - case 2: DeletePhysicalSurface(num); break; - case 3: DeletePhysicalVolume(num); break; + case 0: DeletePhysicalPoint(tag); break; + case 1: DeletePhysicalLine(tag); break; + case 2: DeletePhysicalSurface(tag); break; + case 3: DeletePhysicalVolume(tag); break; } } } else{ - Msg::Error("Unsupported operation on physical %s %d", str.c_str(), num); + Msg::Error("Unsupported operation on physical %s %d", str.c_str(), tag); return false; } _changed = true; @@ -1368,7 +1385,7 @@ bool GEO_Internals::getVertex(int tag, double &x, double &y, double &z) return false; } -gmshSurface *GEO_Internals::newGeometrySphere(int num, int centerTag, int pointTag) +gmshSurface *GEO_Internals::newGeometrySphere(int tag, int centerTag, int pointTag) { Vertex *v1 = FindPoint(centerTag); if(!v1){ @@ -1381,13 +1398,13 @@ gmshSurface *GEO_Internals::newGeometrySphere(int num, int centerTag, int pointT return 0; } return gmshSphere::NewSphere - (num, v1->Pos.X, v1->Pos.Y, v1->Pos.Z, + (tag, v1->Pos.X, v1->Pos.Y, v1->Pos.Z, sqrt((v2->Pos.X - v1->Pos.X) * (v2->Pos.X - v1->Pos.X) + (v2->Pos.Y - v1->Pos.Y) * (v2->Pos.Y - v1->Pos.Y) + (v2->Pos.Z - v1->Pos.Z) * (v2->Pos.Z - v1->Pos.Z))); } -gmshSurface *GEO_Internals::newGeometryPolarSphere(int num, int centerTag, int pointTag) +gmshSurface *GEO_Internals::newGeometryPolarSphere(int tag, int centerTag, int pointTag) { Vertex *v1 = FindPoint(centerTag); if(!v1){ @@ -1400,7 +1417,7 @@ gmshSurface *GEO_Internals::newGeometryPolarSphere(int num, int centerTag, int p return 0; } return gmshPolarSphere::NewPolarSphere - (num, v1->Pos.X, v1->Pos.Y, v1->Pos.Z, + (tag, v1->Pos.X, v1->Pos.Y, v1->Pos.Z, sqrt((v2->Pos.X - v1->Pos.X) * (v2->Pos.X - v1->Pos.X) + (v2->Pos.Y - v1->Pos.Y) * (v2->Pos.Y - v1->Pos.Y) + (v2->Pos.Z - v1->Pos.Z) * (v2->Pos.Z - v1->Pos.Z))); @@ -1661,7 +1678,7 @@ int GModel::exportDiscreteGEOInternals() } // TODO: create Volumes from discreteRegions ; meanwhile, keep track of - // maximum volume num so that we don't break later operations: + // maximum volume tag so that we don't break later operations: _geo_internals->setMaxTag(3, maxv); Msg::Debug("Geo internal model has:"); diff --git a/Geo/GModelIO_GEO.h b/Geo/GModelIO_GEO.h index ba4b76caf1..aaae95e20e 100644 --- a/Geo/GModelIO_GEO.h +++ b/Geo/GModelIO_GEO.h @@ -48,31 +48,31 @@ class GEO_Internals{ void setMaxTag(int dim, int val); int getMaxTag(int dim) const; - // add shapes - bool addVertex(int num, double x, double y, double z, double lc); - bool addVertex(int num, double x, double y, gmshSurface *s, double lc); - bool addLine(int num, int startTag, int endTag); - bool addLine(int num, const std::vector<int> &vertexTags); - bool addCircleArc(int num, int startTag, int centerTag, int EndTag, + // add shapes (if tag is < 0, a new tag is automatically created and returned) + bool addVertex(int &tag, double x, double y, double z, double lc); + bool addVertex(int &tag, double x, double y, gmshSurface *s, double lc); + bool addLine(int &tag, int startTag, int endTag); + bool addLine(int &tag, const std::vector<int> &vertexTags); + bool addCircleArc(int &tag, int startTag, int centerTag, int EndTag, double nx=0., double ny=0., double nz=0.); - bool addEllipseArc(int num, int startTag, int centerTag, int majorTag, + bool addEllipseArc(int &tag, int startTag, int centerTag, int majorTag, int endTag, double nx=0., double ny=0., double nz=0.); - bool addSpline(int num, const std::vector<int> &vertexTags); - bool addBSpline(int num, const std::vector<int> &vertexTags); - bool addBezier(int num, const std::vector<int> &vertexTags); - bool addNurbs(int num, const std::vector<int> &vertexTags, + bool addSpline(int &tag, const std::vector<int> &vertexTags); + bool addBSpline(int &tag, const std::vector<int> &vertexTags); + bool addBezier(int &tag, const std::vector<int> &vertexTags); + bool addNurbs(int &tag, const std::vector<int> &vertexTags, const std::vector<double> &knots); - bool addCompoundLine(int num, const std::vector<int> &edgeTags); - bool addLineLoop(int num, const std::vector<int> &edgeTags); - bool addPlaneSurface(int num, const std::vector<int> &wireTags); - bool addDiscreteSurface(int num); - bool addSurfaceFilling(int num, const std::vector<int> &wireTags, + bool addCompoundLine(int &tag, const std::vector<int> &edgeTags); + bool addLineLoop(int &tag, const std::vector<int> &edgeTags); + bool addPlaneSurface(int &tag, const std::vector<int> &wireTags); + bool addDiscreteSurface(int &tag); + bool addSurfaceFilling(int &tag, const std::vector<int> &wireTags, int sphereCenterTag=-1); - bool addSurfaceLoop(int num, const std::vector<int> &faceTags); - bool addCompoundSurface(int num, const std::vector<int> &faceTags, + bool addSurfaceLoop(int &tag, const std::vector<int> &faceTags); + bool addCompoundSurface(int &tag, const std::vector<int> &faceTags, std::vector<int> edgeTags[4]=0); - bool addVolume(int num, const std::vector<int> &shellTags); - bool addCompoundVolume(int num, const std::vector<int> ®ionTags); + bool addVolume(int &tag, const std::vector<int> &shellTags); + bool addCompoundVolume(int &tag, const std::vector<int> ®ionTags); // extrude and revolve bool extrude(const std::vector<std::pair<int, int> > &inDimTags, @@ -120,7 +120,7 @@ class GEO_Internals{ // manipulate physical groups void resetPhysicalGroups(); - bool modifyPhysicalGroup(int dim, int num, int op, const std::vector<int> &tags); + bool modifyPhysicalGroup(int dim, int tag, int op, const std::vector<int> &tags); int getMaxPhysicalTag() const { return _maxPhysicalNum; } void setMaxPhysicalTag(int val) { _maxPhysicalNum = val; } @@ -148,8 +148,8 @@ class GEO_Internals{ bool getVertex(int tag, double &x, double &y, double &z); // create coordinate systems - gmshSurface *newGeometrySphere(int num, int centerTag, int pointTag); - gmshSurface *newGeometryPolarSphere(int num, int centerTag, int pointTag); + gmshSurface *newGeometrySphere(int tag, int centerTag, int pointTag); + gmshSurface *newGeometryPolarSphere(int tag, int centerTag, int pointTag); }; #endif diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index 799f6b1806..03b5232928 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -550,7 +550,7 @@ TopoDS_Shape OCC_Internals::find(int dim, int tag) bool OCC_Internals::addVertex(int &tag, double x, double y, double z, double meshSize) { - if(tag > 0 && _tagVertex.IsBound(tag)){ + if(tag >= 0 && _tagVertex.IsBound(tag)){ Msg::Error("OpenCASCADE vertex with tag %d already exists", tag); return false; } @@ -571,14 +571,14 @@ bool OCC_Internals::addVertex(int &tag, double x, double y, double z, } if(meshSize > 0 && meshSize < MAX_LC) _meshAttr.Bind(result, meshAttr(meshSize)); - if(tag <= 0) tag = getMaxTag(0) + 1; + if(tag < 0) tag = getMaxTag(0) + 1; bind(result, tag, true); return true; } bool OCC_Internals::addLine(int &tag, int startTag, int endTag) { - if(tag > 0 && _tagEdge.IsBound(tag)){ + if(tag >= 0 && _tagEdge.IsBound(tag)){ Msg::Error("OpenCASCADE edge with tag %d already exists", tag); return false; } @@ -607,7 +607,7 @@ bool OCC_Internals::addLine(int &tag, int startTag, int endTag) Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(1) + 1; + if(tag < 0) tag = getMaxTag(1) + 1; bind(result, tag, true); return true; } @@ -625,7 +625,7 @@ bool OCC_Internals::addLine(int &tag, const std::vector<int> &vertexTags) bool OCC_Internals::_addArc(int &tag, int startTag, int centerTag, int endTag, int mode) { - if(tag > 0 && _tagEdge.IsBound(tag)){ + if(tag >= 0 && _tagEdge.IsBound(tag)){ Msg::Error("OpenCASCADE edge with tag %d already exists", tag); return false; } @@ -688,7 +688,7 @@ bool OCC_Internals::_addArc(int &tag, int startTag, int centerTag, int endTag, Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(1) + 1; + if(tag < 0) tag = getMaxTag(1) + 1; bind(result, tag, true); return true; } @@ -706,7 +706,7 @@ bool OCC_Internals::addEllipseArc(int &tag, int startTag, int centerTag, int end bool OCC_Internals::addCircle(int &tag, double x, double y, double z, double r, double angle1, double angle2) { - if(tag > 0 && _tagEdge.IsBound(tag)){ + if(tag >= 0 && _tagEdge.IsBound(tag)){ Msg::Error("OpenCASCADE edge with tag %d already exists", tag); return false; } @@ -736,7 +736,7 @@ bool OCC_Internals::addCircle(int &tag, double x, double y, double z, double r, Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(1) + 1; + if(tag < 0) tag = getMaxTag(1) + 1; bind(result, tag, true); return true; } @@ -744,7 +744,7 @@ bool OCC_Internals::addCircle(int &tag, double x, double y, double z, double r, bool OCC_Internals::addEllipse(int &tag, double x, double y, double z, double r1, double r2, double angle1, double angle2) { - if(tag > 0 && _tagEdge.IsBound(tag)){ + if(tag >= 0 && _tagEdge.IsBound(tag)){ Msg::Error("OpenCASCADE edge with tag %d already exists", tag); return false; } @@ -774,14 +774,14 @@ bool OCC_Internals::addEllipse(int &tag, double x, double y, double z, double r1 Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(1) + 1; + if(tag < 0) tag = getMaxTag(1) + 1; bind(result, tag, true); return true; } bool OCC_Internals::_addSpline(int &tag, const std::vector<int> &vertexTags, int mode) { - if(tag > 0 && _tagEdge.IsBound(tag)){ + if(tag >= 0 && _tagEdge.IsBound(tag)){ Msg::Error("OpenCASCADE edge with tag %d already exists", tag); return false; } @@ -834,7 +834,7 @@ bool OCC_Internals::_addSpline(int &tag, const std::vector<int> &vertexTags, int Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(1) + 1; + if(tag < 0) tag = getMaxTag(1) + 1; bind(result, tag, true); return true; } @@ -857,7 +857,7 @@ bool OCC_Internals::addBSpline(int &tag, const std::vector<int> &vertexTags) bool OCC_Internals::addWire(int &tag, const std::vector<int> &edgeTags, bool checkClosed) { - if(tag > 0 && _tagWire.IsBound(tag)){ + if(tag >= 0 && _tagWire.IsBound(tag)){ Msg::Error("OpenCASCADE wire or line loop with tag %d already exists", tag); return false; } @@ -883,7 +883,7 @@ bool OCC_Internals::addWire(int &tag, const std::vector<int> &edgeTags, Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(-1) + 1; + if(tag < 0) tag = getMaxTag(-1) + 1; bind(result, tag, true); return true; } @@ -896,7 +896,7 @@ bool OCC_Internals::addLineLoop(int &tag, const std::vector<int> &edgeTags) bool OCC_Internals::addRectangle(int &tag, double x, double y, double z, double dx, double dy, double roundedRadius) { - if(tag > 0 && _tagFace.IsBound(tag)){ + if(tag >= 0 && _tagFace.IsBound(tag)){ Msg::Error("OpenCASCADE face with tag %d already exists", tag); return false; } @@ -961,7 +961,7 @@ bool OCC_Internals::addRectangle(int &tag, double x, double y, double z, Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(2) + 1; + if(tag < 0) tag = getMaxTag(2) + 1; bind(result, tag, true); return true; } @@ -969,7 +969,7 @@ bool OCC_Internals::addRectangle(int &tag, double x, double y, double z, bool OCC_Internals::addDisk(int &tag, double xc, double yc, double zc, double rx, double ry) { - if(tag > 0 && _tagFace.IsBound(tag)){ + if(tag >= 0 && _tagFace.IsBound(tag)){ Msg::Error("OpenCASCADE face with tag %d already exists", tag); return false; } @@ -989,7 +989,7 @@ bool OCC_Internals::addDisk(int &tag, double xc, double yc, double zc, Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(2) + 1; + if(tag < 0) tag = getMaxTag(2) + 1; bind(result, tag, true); return true; } @@ -998,7 +998,7 @@ bool OCC_Internals::addPlaneSurface(int &tag, const std::vector<int> &wireTags) { const bool autoFix = true; - if(tag > 0 && _tagFace.IsBound(tag)){ + if(tag >= 0 && _tagFace.IsBound(tag)){ Msg::Error("OpenCASCADE face with tag %d already exists", tag); return false; } @@ -1064,14 +1064,14 @@ bool OCC_Internals::addPlaneSurface(int &tag, const std::vector<int> &wireTags) return false; } } - if(tag <= 0) tag = getMaxTag(2) + 1; + if(tag < 0) tag = getMaxTag(2) + 1; bind(result, tag, true); return true; } bool OCC_Internals::addSurfaceFilling(int &tag, int wireTag) { - if(tag > 0 && _tagFace.IsBound(tag)){ + if(tag >= 0 && _tagFace.IsBound(tag)){ Msg::Error("OpenCASCADE face with tag %d already exists", tag); return false; } @@ -1104,7 +1104,7 @@ bool OCC_Internals::addSurfaceFilling(int &tag, int wireTag) return false; } - if(tag <= 0) tag = getMaxTag(2) + 1; + if(tag < 0) tag = getMaxTag(2) + 1; bind(result, tag, true); return true; } @@ -1113,7 +1113,7 @@ bool OCC_Internals::addSurfaceLoop(int &tag, const std::vector<int> &faceTags) { const bool autoFix = true; - if(tag > 0 && _tagShell.IsBound(tag)){ + if(tag >= 0 && _tagShell.IsBound(tag)){ Msg::Error("OpenCASCADE surface loop with tag %d already exists", tag); return false; } @@ -1164,7 +1164,7 @@ bool OCC_Internals::addVolume(int &tag, const std::vector<int> &shellTags) { const bool autoFix = true; - if(tag > 0 && _tagSolid.IsBound(tag)){ + if(tag >= 0 && _tagSolid.IsBound(tag)){ Msg::Error("OpenCASCADE region with tag %d already exists", tag); return false; } @@ -1192,7 +1192,7 @@ bool OCC_Internals::addVolume(int &tag, const std::vector<int> &shellTags) Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(3) + 1; + if(tag < 0) tag = getMaxTag(3) + 1; bind(result, tag, true); return true; } @@ -1201,7 +1201,7 @@ bool OCC_Internals::addSphere(int &tag, double xc, double yc, double zc, double radius, double angle1, double angle2, double angle3) { - if(tag > 0 && _tagSolid.IsBound(tag)){ + if(tag >= 0 && _tagSolid.IsBound(tag)){ Msg::Error("OpenCASCADE region with tag %d already exists", tag); return false; } @@ -1221,7 +1221,7 @@ bool OCC_Internals::addSphere(int &tag, double xc, double yc, double zc, Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(3) + 1; + if(tag < 0) tag = getMaxTag(3) + 1; bind(result, tag, true); return true; } @@ -1229,7 +1229,7 @@ bool OCC_Internals::addSphere(int &tag, double xc, double yc, double zc, bool OCC_Internals::addBlock(int &tag, double x, double y, double z, double dx, double dy, double dz) { - if(tag > 0 && _tagSolid.IsBound(tag)){ + if(tag >= 0 && _tagSolid.IsBound(tag)){ Msg::Error("OpenCASCADE region with tag %d already exists", tag); return false; } @@ -1250,7 +1250,7 @@ bool OCC_Internals::addBlock(int &tag, double x, double y, double z, Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(3) + 1; + if(tag < 0) tag = getMaxTag(3) + 1; bind(result, tag, true); return true; } @@ -1259,7 +1259,7 @@ bool OCC_Internals::addCylinder(int &tag, double x, double y, double z, double dx, double dy, double dz, double r, double angle) { - if(tag > 0 && _tagSolid.IsBound(tag)){ + if(tag >= 0 && _tagSolid.IsBound(tag)){ Msg::Error("OpenCASCADE region with tag %d already exists", tag); return false; } @@ -1285,7 +1285,7 @@ bool OCC_Internals::addCylinder(int &tag, double x, double y, double z, Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(3) + 1; + if(tag < 0) tag = getMaxTag(3) + 1; bind(result, tag, true); return true; } @@ -1293,7 +1293,7 @@ bool OCC_Internals::addCylinder(int &tag, double x, double y, double z, bool OCC_Internals::addTorus(int &tag, double x, double y, double z, double r1, double r2, double angle) { - if(tag > 0 && _tagSolid.IsBound(tag)){ + if(tag >= 0 && _tagSolid.IsBound(tag)){ Msg::Error("OpenCASCADE region with tag %d already exists", tag); return false; } @@ -1314,7 +1314,7 @@ bool OCC_Internals::addTorus(int &tag, double x, double y, double z, Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(3) + 1; + if(tag < 0) tag = getMaxTag(3) + 1; bind(result, tag, true); return true; } @@ -1323,7 +1323,7 @@ bool OCC_Internals::addCone(int &tag, double x, double y, double z, double dx, double dy, double dz, double r1, double r2, double angle) { - if(tag > 0 && _tagSolid.IsBound(tag)){ + if(tag >= 0 && _tagSolid.IsBound(tag)){ Msg::Error("OpenCASCADE region with tag %d already exists", tag); return false; } @@ -1350,7 +1350,7 @@ bool OCC_Internals::addCone(int &tag, double x, double y, double z, Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(3) + 1; + if(tag < 0) tag = getMaxTag(3) + 1; bind(result, tag, true); return true; } @@ -1358,7 +1358,7 @@ bool OCC_Internals::addCone(int &tag, double x, double y, double z, bool OCC_Internals::addWedge(int &tag, double x, double y, double z, double dx, double dy, double dz, double ltx) { - if(tag > 0 && _tagSolid.IsBound(tag)){ + if(tag >= 0 && _tagSolid.IsBound(tag)){ Msg::Error("OpenCASCADE region with tag %d already exists", tag); return false; } @@ -1380,7 +1380,7 @@ bool OCC_Internals::addWedge(int &tag, double x, double y, double z, Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); return false; } - if(tag <= 0) tag = getMaxTag(3) + 1; + if(tag < 0) tag = getMaxTag(3) + 1; bind(result, tag, true); return true; } @@ -1390,7 +1390,7 @@ bool OCC_Internals::addThruSections(int tag, const std::vector<int> &wireTags, std::vector<std::pair<int, int> > &outDimTags) { int dim = makeSolid ? 3 : 2; - if(tag > 0 && isBound(dim, tag)){ + if(tag >= 0 && isBound(dim, tag)){ Msg::Error("OpenCASCADE entity of dimension %d with tag %d already exists", dim, tag); return false; @@ -1437,7 +1437,7 @@ bool OCC_Internals::addThickSolid(int tag, int solidTag, double offset, std::vector<std::pair<int, int> > &outDimTags) { - if(tag > 0 && isBound(3, tag)){ + if(tag >= 0 && isBound(3, tag)){ Msg::Error("OpenCASCADE region with tag %d already exists", tag); return false; } @@ -1787,7 +1787,7 @@ bool OCC_Internals::applyBooleanOperator if(objectDimTags.empty()) return true; - if(tag > 0 && isBound(objectDimTags[0].first, tag)){ + if(tag >= 0 && isBound(objectDimTags[0].first, tag)){ Msg::Error("OpenCASCADE entity with tag %d already exists", tag); return false; } -- GitLab