diff --git a/Geo/GModelIO_GEO.cpp b/Geo/GModelIO_GEO.cpp index 41f21f3db9e8754921846a1075895f1d0f856f0b..c9456eac3d784c83cba588897863d952eb82e4cc 100644 --- a/Geo/GModelIO_GEO.cpp +++ b/Geo/GModelIO_GEO.cpp @@ -131,15 +131,17 @@ void GEO_Internals::addLine(int num, int startTag, int endTag) _changed = true; } -void GEO_Internals::addLine(int num, std::vector<int> vertexTags) +void GEO_Internals::addLine(int num, const std::vector<int> &vertexTags) { if(FindCurve(num)){ Msg::Error("GEO edge with tag %d already exists", num); return; } List_T *tmp = List_Create(2, 2, sizeof(int)); - for(unsigned int i = 0; i < vertexTags.size(); i++) - List_Add(tmp, &vertexTags[i]); + 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.); Tree_Add(Curves, &c); CreateReversedCurve(c); @@ -208,15 +210,17 @@ void GEO_Internals::addEllipseArc(int num, int startTag, int centerTag, int majo _changed = true; } -void GEO_Internals::addSpline(int num, std::vector<int> vertexTags) +void GEO_Internals::addSpline(int num, const std::vector<int> &vertexTags) { if(FindCurve(num)){ Msg::Error("GEO edge with tag %d already exists", num); return; } List_T *tmp = List_Create(2, 2, sizeof(int)); - for(unsigned int i = 0; i < vertexTags.size(); i++) - List_Add(tmp, &vertexTags[i]); + 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.); Tree_Add(Curves, &c); CreateReversedCurve(c); @@ -224,15 +228,17 @@ void GEO_Internals::addSpline(int num, std::vector<int> vertexTags) _changed = true; } -void GEO_Internals::addBSpline(int num, std::vector<int> vertexTags) +void GEO_Internals::addBSpline(int num, const std::vector<int> &vertexTags) { if(FindCurve(num)){ Msg::Error("GEO edge with tag %d already exists", num); return; } List_T *tmp = List_Create(2, 2, sizeof(int)); - for(unsigned int i = 0; i < vertexTags.size(); i++) - List_Add(tmp, &vertexTags[i]); + 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.); Tree_Add(Curves, &c); CreateReversedCurve(c); @@ -240,15 +246,17 @@ void GEO_Internals::addBSpline(int num, std::vector<int> vertexTags) _changed = true; } -void GEO_Internals::addBezier(int num, std::vector<int> vertexTags) +void GEO_Internals::addBezier(int num, const std::vector<int> &vertexTags) { if(FindCurve(num)){ Msg::Error("GEO edge with tag %d already exists", num); return; } List_T *tmp = List_Create(2, 2, sizeof(int)); - for(unsigned int i = 0; i < vertexTags.size(); i++) - List_Add(tmp, &vertexTags[i]); + for(unsigned int i = 0; i < vertexTags.size(); i++){ + int t = vertexTags[i]; + List_Add(tmp, &t); + } Curve *c = CreateCurve(num, MSH_SEGM_BEZIER, 2, tmp, NULL, -1, -1, 0., 1.); Tree_Add(Curves, &c); CreateReversedCurve(c); @@ -256,8 +264,8 @@ void GEO_Internals::addBezier(int num, std::vector<int> vertexTags) _changed = true; } -void GEO_Internals::addNurbs(int num, std::vector<int> vertexTags, - std::vector<double> knots) +void GEO_Internals::addNurbs(int num, const std::vector<int> &vertexTags, + const std::vector<double> &knots) { if(FindCurve(num)){ Msg::Error("GEO edge with tag %d already exists", num); @@ -265,11 +273,15 @@ void GEO_Internals::addNurbs(int num, std::vector<int> vertexTags, } 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++) - List_Add(tmp, &vertexTags[i]); + for(unsigned int i = 0; i < vertexTags.size(); i++){ + int t = vertexTags[i]; + List_Add(tmp, &t); + } List_T *knotsList = List_Create(2, 2, sizeof(double)); - for(unsigned int i = 0; i < knots.size(); i++) - List_Add(knotsList, &knots[i]); + for(unsigned int i = 0; i < knots.size(); i++){ + double d = knots[i]; + List_Add(knotsList, &d); + } Curve *c = CreateCurve(num, MSH_SEGM_NURBS, order, tmp, knotsList, -1, -1, 0., 1.); Tree_Add(Curves, &c); CreateReversedCurve(c); @@ -277,7 +289,7 @@ void GEO_Internals::addNurbs(int num, std::vector<int> vertexTags, _changed = true; } -void GEO_Internals::addCompoundLine(int num, std::vector<int> edgeTags) +void GEO_Internals::addCompoundLine(int num, const std::vector<int> &edgeTags) { if(FindCurve(num)){ Msg::Error("GEO edge with tag %d already exists", num); @@ -292,15 +304,17 @@ void GEO_Internals::addCompoundLine(int num, std::vector<int> edgeTags) _changed = true; } -void GEO_Internals::addLineLoop(int num, std::vector<int> edgeTags) +void GEO_Internals::addLineLoop(int num, const std::vector<int> &edgeTags) { if(FindEdgeLoop(num)){ Msg::Error("GEO line loop with tag %d already exists", num); return; } List_T *tmp = List_Create(2, 2, sizeof(int)); - for(unsigned int i = 0; i < edgeTags.size(); i++) - List_Add(tmp, &edgeTags[i]); + 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); Tree_Add(EdgeLoops, &l); @@ -308,7 +322,7 @@ void GEO_Internals::addLineLoop(int num, std::vector<int> edgeTags) _changed = true; } -void GEO_Internals::addPlaneSurface(int num, std::vector<int> wireTags) +void GEO_Internals::addPlaneSurface(int num, const std::vector<int> &wireTags) { if(FindSurface(num)){ Msg::Error("GEO face with tag %d already exists", num); @@ -319,8 +333,10 @@ void GEO_Internals::addPlaneSurface(int num, std::vector<int> wireTags) return; } List_T *tmp = List_Create(2, 2, sizeof(int)); - for(unsigned int i = 0; i < wireTags.size(); i++) - List_Add(tmp, &wireTags[i]); + for(unsigned int i = 0; i < wireTags.size(); i++){ + int t = wireTags[i]; + List_Add(tmp, &t); + } Surface *s = CreateSurface(num, MSH_SURF_PLAN); SetSurfaceGeneratrices(s, tmp); List_Delete(tmp); @@ -340,7 +356,7 @@ void GEO_Internals::addDiscreteSurface(int num) _changed = true; } -void GEO_Internals::addSurfaceFilling(int num, std::vector<int> wireTags, +void GEO_Internals::addSurfaceFilling(int num, const std::vector<int> &wireTags, int sphereCenterTag) { if(FindSurface(num)){ @@ -366,8 +382,10 @@ void GEO_Internals::addSurfaceFilling(int num, std::vector<int> wireTags, Msg::Error("Wrong definition of face %d: %d borders instead of 3 or 4", num, j); List_T *tmp = List_Create(2, 2, sizeof(int)); - for(unsigned int i = 0; i < wireTags.size(); i++) - List_Add(tmp, &wireTags[i]); + for(unsigned int i = 0; i < wireTags.size(); i++){ + int t = wireTags[i]; + List_Add(tmp, &t); + } Surface *s = CreateSurface(num, type); SetSurfaceGeneratrices(s, tmp); List_Delete(tmp); @@ -381,7 +399,7 @@ void GEO_Internals::addSurfaceFilling(int num, std::vector<int> wireTags, _changed = true; } -void GEO_Internals::addCompoundSurface(int num, std::vector<int> faceTags, +void GEO_Internals::addCompoundSurface(int num, const std::vector<int> &faceTags, std::vector<int> edgeTags[4]) { if(FindSurface(num)){ @@ -400,7 +418,7 @@ void GEO_Internals::addCompoundSurface(int num, std::vector<int> faceTags, _changed = true; } -void GEO_Internals::addSurfaceLoop(int num, std::vector<int> faceTags) +void GEO_Internals::addSurfaceLoop(int num, const std::vector<int> &faceTags) { if(FindSurfaceLoop(num)){ Msg::Error("GEO surface loop with tag %d already exists", num); @@ -408,15 +426,17 @@ void GEO_Internals::addSurfaceLoop(int num, std::vector<int> faceTags) } List_T *tmp = List_Create(2, 2, sizeof(int)); - for(unsigned int i = 0; i < faceTags.size(); i++) - List_Add(tmp, &faceTags[i]); + for(unsigned int i = 0; i < faceTags.size(); i++){ + int t = faceTags[i]; + List_Add(tmp, &t); + } SurfaceLoop *l = CreateSurfaceLoop(num, tmp); Tree_Add(SurfaceLoops, &l); List_Delete(tmp); _changed = true; } -void GEO_Internals::addVolume(int num, std::vector<int> shellTags) +void GEO_Internals::addVolume(int num, const std::vector<int> &shellTags) { if(FindVolume(num)){ Msg::Error("GEO region with tag %d already exists", num); @@ -424,8 +444,10 @@ void GEO_Internals::addVolume(int num, std::vector<int> shellTags) } List_T *tmp = List_Create(2, 2, sizeof(int)); - for(unsigned int i = 0; i < shellTags.size(); i++) - List_Add(tmp, &shellTags[i]); + for(unsigned int i = 0; i < shellTags.size(); i++){ + int t = shellTags[i]; + List_Add(tmp, &t); + } Volume *v = CreateVolume(num, MSH_VOLUME); SetVolumeSurfaces(v, tmp); List_Delete(tmp); @@ -433,7 +455,7 @@ void GEO_Internals::addVolume(int num, std::vector<int> shellTags) _changed = true; } -void GEO_Internals::addCompoundVolume(int num, std::vector<int> regionTags) +void GEO_Internals::addCompoundVolume(int num, const std::vector<int> ®ionTags) { if(FindVolume(num)){ Msg::Error("GEO region with tag %d already exists", num); @@ -689,7 +711,8 @@ void GEO_Internals::resetPhysicalGroups() _changed = true; } -void GEO_Internals::modifyPhysicalGroup(int dim, int num, int op, std::vector<int> tags) +void GEO_Internals::modifyPhysicalGroup(int dim, int num, int op, + const std::vector<int> &tags) { int type; std::string str; @@ -709,20 +732,24 @@ void GEO_Internals::modifyPhysicalGroup(int dim, int num, int op, std::vector<in } else if(op == 0){ List_T *tmp = List_Create(10, 10, sizeof(int)); - for(unsigned int i = 0; i < tags.size(); i++) - List_Add(tmp, &tags[i]); + for(unsigned int i = 0; i < tags.size(); i++){ + int t = tags[i]; + List_Add(tmp, &t); + } p = CreatePhysicalGroup(num, type, tmp); List_Delete(tmp); List_Add(PhysicalGroups, &p); } else if(op == 1){ for(unsigned int i = 0; i < tags.size(); i++){ - List_Add(p->Entities, &tags[i]); + int t = tags[i]; + List_Add(p->Entities, &t); } } else if(op == 2){ for(unsigned int i = 0; i < tags.size(); i++){ - List_Suppress(p->Entities, &tags[i], fcmp_int); + int t = tags[i]; + List_Suppress(p->Entities, &t, fcmp_int); } if(!List_Nbr(p->Entities)){ switch(dim){ @@ -745,7 +772,7 @@ void GEO_Internals::removeAllDuplicates() _changed = true; } -void GEO_Internals::mergeVertices(std::vector<int> tags) +void GEO_Internals::mergeVertices(const std::vector<int> &tags) { if(tags.size() < 2) return; Vertex *target = FindPoint(tags[0]); @@ -772,7 +799,7 @@ void GEO_Internals::mergeVertices(std::vector<int> tags) _changed = true; } -void GEO_Internals::setCompoundMesh(int dim, std::vector<int> tags) +void GEO_Internals::setCompoundMesh(int dim, const std::vector<int> &tags) { _meshCompounds.insert(std::make_pair(dim, tags)); _changed = true; @@ -824,7 +851,7 @@ void GEO_Internals::setTransfiniteLine(int tag, int nPoints, int type, double co } void GEO_Internals::setTransfiniteSurface(int tag, int arrangement, - std::vector<int> cornerTags) + const std::vector<int> &cornerTags) { if(!tag){ List_T *tmp = Tree2List(Surfaces); @@ -860,7 +887,7 @@ void GEO_Internals::setTransfiniteSurface(int tag, int arrangement, _changed = true; } -void GEO_Internals::setTransfiniteVolume(int tag, std::vector<int> cornerTags) +void GEO_Internals::setTransfiniteVolume(int tag, const std::vector<int> &cornerTags) { if(!tag){ List_T *tmp = Tree2List(Volumes); diff --git a/Geo/GModelIO_GEO.h b/Geo/GModelIO_GEO.h index 34d08fac22d57eb2923774fc50782e3e04fd8dc6..00f49a0b7127388e2920f6c7ca75d7e3c92f3f92 100644 --- a/Geo/GModelIO_GEO.h +++ b/Geo/GModelIO_GEO.h @@ -52,25 +52,27 @@ class GEO_Internals{ void addVertex(int num, double x, double y, double z, double lc); void addVertex(int num, double x, double y, gmshSurface *s, double lc); void addLine(int num, int startTag, int endTag); - void addLine(int num, std::vector<int> vertexTags); + void addLine(int num, const std::vector<int> &vertexTags); void addCircleArc(int num, int startTag, int centerTag, int EndTag, double nx=0., double ny=0., double nz=0.); void addEllipseArc(int num, int startTag, int centerTag, int majorTag, int endTag, double nx=0., double ny=0., double nz=0.); - void addSpline(int num, std::vector<int> vertexTags); - void addBSpline(int num, std::vector<int> vertexTags); - void addBezier(int num, std::vector<int> vertexTags); - void addNurbs(int num, std::vector<int> vertexTags, std::vector<double> knots); - void addCompoundLine(int num, std::vector<int> edgeTags); - void addLineLoop(int num, std::vector<int> edgeTags); - void addPlaneSurface(int num, std::vector<int> wireTags); + void addSpline(int num, const std::vector<int> &vertexTags); + void addBSpline(int num, const std::vector<int> &vertexTags); + void addBezier(int num, const std::vector<int> &vertexTags); + void addNurbs(int num, const std::vector<int> &vertexTags, + const std::vector<double> &knots); + void addCompoundLine(int num, const std::vector<int> &edgeTags); + void addLineLoop(int num, const std::vector<int> &edgeTags); + void addPlaneSurface(int num, const std::vector<int> &wireTags); void addDiscreteSurface(int num); - void addSurfaceFilling(int num, std::vector<int> wireTags, int sphereCenterTag=-1); - void addSurfaceLoop(int num, std::vector<int> faceTags); - void addCompoundSurface(int num, std::vector<int> faceTags, + void addSurfaceFilling(int num, const std::vector<int> &wireTags, + int sphereCenterTag=-1); + void addSurfaceLoop(int num, const std::vector<int> &faceTags); + void addCompoundSurface(int num, const std::vector<int> &faceTags, std::vector<int> edgeTags[4]=0); - void addVolume(int num, std::vector<int> shellTags); - void addCompoundVolume(int num, std::vector<int> regionTags); + void addVolume(int num, const std::vector<int> &shellTags); + void addCompoundVolume(int num, const std::vector<int> ®ionTags); // extrude and revolve void extrude(const std::vector<std::pair<int, int> > &inDimTags, @@ -117,21 +119,22 @@ class GEO_Internals{ // manipulate physical groups void resetPhysicalGroups(); - void modifyPhysicalGroup(int dim, int num, int op, std::vector<int> tags); + void modifyPhysicalGroup(int dim, int num, int op, const std::vector<int> &tags); int getMaxPhysicalTag() const { return _maxPhysicalNum; } void setMaxPhysicalTag(int val) { _maxPhysicalNum = val; } // coherence void removeAllDuplicates(); - void mergeVertices(std::vector<int> tags); + void mergeVertices(const std::vector<int> &tags); // set meshing constraints - void setCompoundMesh(int dim, std::vector<int> tags); + void setCompoundMesh(int dim, const std::vector<int> &tags); void setMeshSize(int dim, int tag, double size); void setDegenerated(int dim, int tag); void setTransfiniteLine(int tag, int nPoints, int type, double coef); - void setTransfiniteSurface(int tag, int arrangement, std::vector<int> cornerTags); - void setTransfiniteVolume(int tag, std::vector<int> cornerTags); + void setTransfiniteSurface(int tag, int arrangement, + const std::vector<int> &cornerTags); + void setTransfiniteVolume(int tag, const std::vector<int> &cornerTags); void setTransfiniteVolumeQuadTri(int tag); void setRecombine(int dim, int tag, double angle); void setSmoothing(int tag, int val); diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index a1ed44ee54bf4476181dd254b4f1f5a18d064881..8b893dceb1b49d10bbce785e624264828473e27f 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -819,7 +819,6 @@ Affectation : } Free($1); } - | String__Index LP RP NumericAffectation ListOfDouble tEND { gmsh_yysymbol &s(gmsh_yysymbols[$1]); @@ -849,7 +848,6 @@ Affectation : Free($1); List_Delete($5); } - | String__Index LP '{' RecursiveListOfDouble '}' RP NumericAffectation ListOfDouble tEND { assignVariables($1, $4, $7, $8); @@ -893,8 +891,8 @@ Affectation : Free($3); } - // lists of strings with bracket notation - // lists of strings with parentheses notation + // lists of strings + | String__Index LP RP tAFFECT tStr LP RP tEND { gmsh_yystringsymbols[$1] = std::vector<std::string>(); @@ -935,7 +933,6 @@ Affectation : StringOption(GMSH_SET|GMSH_GUI, $1, 0, $3, tmp); Free($1); Free($3); Free($5); } - | String__Index '[' FExpr ']' '.' tSTRING tAFFECT StringExpr tEND { std::string tmp($8); @@ -963,7 +960,6 @@ Affectation : } Free($1); Free($3); } - | String__Index '[' FExpr ']' '.' tSTRING NumericAffectation FExpr tEND { double d = 0.; @@ -982,7 +978,6 @@ Affectation : } Free($1); Free($6); } - | String__Index '.' tSTRING NumericIncrement tEND { double d = 0.; @@ -992,7 +987,6 @@ Affectation : } Free($1); Free($3); } - | String__Index '[' FExpr ']' '.' tSTRING NumericIncrement tEND { double d = 0.; @@ -1010,7 +1004,6 @@ Affectation : ColorOption(GMSH_SET|GMSH_GUI, $1, 0, $5, $7); Free($1); Free($5); } - | String__Index '[' FExpr ']' '.' tColor '.' tSTRING tAFFECT ColorExpr tEND { ColorOption(GMSH_SET|GMSH_GUI, $1, (int)$3, $8, $10); @@ -1039,7 +1032,6 @@ Affectation : Free($1); List_Delete($5); } - | String__Index '[' FExpr ']' '.' tColorTable tAFFECT ListOfColor tEND { GmshColorTable *ct = GetColorTable((int)$3); @@ -4866,14 +4858,14 @@ FExpr_Single : */ } | String__Index tSCOPE String__Index '.' tSTRING_Member_Float - { $$ = treat_Struct_FullName_dot_tSTRING_Float($1, $3, $5); } - + { + $$ = treat_Struct_FullName_dot_tSTRING_Float($1, $3, $5); + } | String__Index '[' FExpr ']' '.' tSTRING { NumberOption(GMSH_GET, $1, (int)$3, $6, $$); Free($1); Free($6); } - | String__Index '.' tSTRING NumericIncrement { double d = 0.; @@ -4884,7 +4876,6 @@ FExpr_Single : } Free($1); Free($3); } - | String__Index '[' FExpr ']' '.' tSTRING NumericIncrement { double d = 0.;