diff --git a/Geo/GEdgeCompound.cpp b/Geo/GEdgeCompound.cpp index 6b79a31df1d92c4f1004cd07f9546ca77455b124..8248973bf92f86eeb01382f97670380f7a4e6a64 100644 --- a/Geo/GEdgeCompound.cpp +++ b/Geo/GEdgeCompound.cpp @@ -14,11 +14,11 @@ #include "Numeric.h" #include "Curvature.h" -GEdgeCompound::GEdgeCompound(GModel *m, int tag, std::vector<GEdge*> &compound, +GEdgeCompound::GEdgeCompound(GModel *m, int tag, std::vector<GEdge*> &compound, std::vector<int> &orientation) : GEdge(m, tag, 0, 0), _compound(compound), _orientation(orientation) { - + int N = _compound.size(); v0 = _orientation[0] ? _compound[0]->getBeginVertex() : _compound[0]->getEndVertex(); v1 = _orientation[N-1] ? _compound[N-1]->getEndVertex() : _compound[N-1]->getBeginVertex(); @@ -30,8 +30,8 @@ GEdgeCompound::GEdgeCompound(GModel *m, int tag, std::vector<GEdge*> &compound, for(std::vector<GEdge*>::iterator it = _compound.begin(); it != _compound.end(); ++it){ if(!(*it)){ - Msg::Error("Incorrect edge in compound edge %d\n", tag); - Msg::Exit(1); + Msg::Error("Incorrect edge in compound edge %d", tag); + return; } } @@ -56,8 +56,8 @@ GEdgeCompound::GEdgeCompound(GModel *m, int tag, std::vector<GEdge*> &compound) void GEdgeCompound::orderEdges() { - std::vector<GEdge*> _c ; - std::list<GEdge*> edges ; + std::vector<GEdge*> _c ; + std::list<GEdge*> edges ; for (unsigned int i = 0; i < _compound.size(); i++){ edges.push_back(_compound[i]); @@ -89,7 +89,7 @@ void GEdgeCompound::orderEdges() edges.erase(it); break; } - } + } } else if (tempv.size() == 0){ // periodic firstEdge = *(edges.begin()); @@ -101,11 +101,11 @@ void GEdgeCompound::orderEdges() } // loop over all segments to order segments and store it in the list _c - _c.push_back(firstEdge); + _c.push_back(firstEdge); _orientation.push_back(1); GVertex *first = _c[0]->getBeginVertex(); - GVertex *last = _c[0]->getEndVertex(); - + GVertex *last = _c[0]->getEndVertex(); + while (first != last){ if (edges.empty())break; bool found = false; @@ -113,7 +113,7 @@ void GEdgeCompound::orderEdges() GEdge *e = *it; std::list<GEdge*>::iterator itp; if (e->getBeginVertex() == last){ - _c.push_back(e); + _c.push_back(e); itp = it; it++; edges.erase(itp); @@ -123,7 +123,7 @@ void GEdgeCompound::orderEdges() break; } else if (e->getEndVertex() == last){ - _c.push_back(e); + _c.push_back(e); itp = it; it++; edges.erase(itp); @@ -145,15 +145,15 @@ void GEdgeCompound::orderEdges() return; } } - } + } //edges is now a list of ordered GEdges _compound = _c; - //special case reverse orientation + //special case reverse orientation if (_compound.size() < 2)return; - if (_orientation[0] && _compound[0]->getEndVertex() != _compound[1]->getEndVertex() - && _compound[0]->getEndVertex() != _compound[1]->getBeginVertex()){ + if (_orientation[0] && _compound[0]->getEndVertex() != _compound[1]->getEndVertex() + && _compound[0]->getEndVertex() != _compound[1]->getBeginVertex()){ for (unsigned int i = 0; i < _compound.size(); i++){ _orientation[i] = !_orientation[i] ; } @@ -163,7 +163,7 @@ void GEdgeCompound::orderEdges() int GEdgeCompound::minimumMeshSegments() const { // int N = 0; - // for (unsigned int i = 0; i < _compound.size(); i++) + // for (unsigned int i = 0; i < _compound.size(); i++) // N +=_compound[i]->minimumMeshSegments(); return 3; } @@ -181,8 +181,8 @@ GEdgeCompound::~GEdgeCompound() } Range<double> GEdgeCompound::parBounds(int i) const -{ - return Range<double>(0, _pars[_compound.size()]); +{ + return Range<double>(0, _pars[_compound.size()]); } /* @@ -198,7 +198,7 @@ void GEdgeCompound::getLocalParameter(const double &t, for (iEdge = 0; iEdge < (int)_compound.size(); iEdge++){ double tmin = _pars[iEdge]; double tmax = _pars[iEdge+1]; - if (t >= tmin && t <= tmax){ + if (t >= tmin && t <= tmax){ Range<double> b = _compound[iEdge]->parBounds(0); tLoc = _orientation[iEdge] ? b.low() + (t-tmin)/(tmax-tmin) * (b.high()-b.low()) : @@ -217,7 +217,7 @@ void GEdgeCompound::getCompoundParameter(GEdge *ge, double tmin = _pars[iEdge]; double tmax = _pars[iEdge+1]; Range<double> b = _compound[iEdge]->parBounds(0); - t = _orientation[iEdge] ? + t = _orientation[iEdge] ? tmin + (tLoc - b.low())/(b.high()-b.low()) * (tmax-tmin): tmax - (tLoc - b.low())/(b.high()-b.low()) * (tmax-tmin); return; @@ -225,13 +225,13 @@ void GEdgeCompound::getCompoundParameter(GEdge *ge, } } -void GEdgeCompound::parametrize() +void GEdgeCompound::parametrize() { _pars.push_back(0.0); for (unsigned int i = 0; i < _compound.size(); i++){ Range<double> b = _compound[i]->parBounds(0); _pars.push_back(_pars[_pars.size()-1]+(b.high() - b.low())); - } + } } double GEdgeCompound::curvature(double par) const @@ -302,7 +302,7 @@ SVector3 GEdgeCompound::firstDer(double par) const int iEdge; getLocalParameter(par,iEdge,tLoc); return _compound[iEdge]->firstDer(tLoc); -} +} void replaceMeshCompound(GFace *gf, std::list<GEdge*> &edges) { @@ -314,7 +314,7 @@ void replaceMeshCompound(GFace *gf, std::list<GEdge*> &edges) if((*it)->getCompound()){ mySet.insert((*it)->getCompound()); } - else{ + else{ mySet.insert(*it); } ++it; diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp index d495b8de049590ebab2c0d8d5d4092fcfb11e0f6..ff9005b3fcb2dca8c5ba3ac4ea62f1b354a188e2 100644 --- a/Geo/GFaceCompound.cpp +++ b/Geo/GFaceCompound.cpp @@ -861,7 +861,10 @@ bool GFaceCompound::parametrize() const if (_type != SQUARE){ bool success = orderVertices(_U0, _ordered, _coords); - if(!success) {Msg::Error("Could not order vertices on boundary");exit(1);} + if(!success) { + Msg::Error("Could not order vertices on boundary"); + return false; + } } fillNeumannBCS_Plane(); @@ -1153,7 +1156,7 @@ GFaceCompound::GFaceCompound(GModel *m, int tag, std::list<GFace*> &compound, for(std::list<GFace*>::iterator it = _compound.begin(); it != _compound.end(); ++it){ if(!(*it)){ Msg::Error("Incorrect face in compound surface %d\n", tag); - Msg::Exit(1); + return; } } @@ -1204,7 +1207,7 @@ GFaceCompound::GFaceCompound(GModel *m, int tag, std::list<GFace*> &compound, for(std::list<GFace*>::iterator it = _compound.begin(); it != _compound.end(); ++it){ if(!(*it)){ Msg::Error("Incorrect face in compound surface %d\n", tag); - Msg::Exit(1); + return; } } @@ -1316,15 +1319,15 @@ SPoint2 GFaceCompound::getCoordinates(MVertex *v) const if(vR->getPolynomialOrder() > 1){ j++; continue; } vR->getParameter(0,tR); if(!vR->getParameter(0,tR)) { - Msg::Error("vertex vr %p not MedgeVertex", vR); - Msg::Exit(1); + Msg::Error("Vertex vr %p not an MEdgeVertex", vR); + return SPoint2(); } if(tLoc > tL && tLoc < tR){ found = true; itR = coordinates.find(vR); if(itR == coordinates.end()){ - Msg::Error("vertex %p (%g %g %g) not found", vR, vR->x(), vR->y(), vR->z()); - Msg::Exit(1); + Msg::Error("Vertex %p (%g %g %g) not found", vR, vR->x(), vR->y(), vR->z()); + return SPoint2(0,0); } break; } @@ -2021,8 +2024,7 @@ GPoint GFaceCompound::pointInRemeshedOctree(double par1, double par2) const //printf("found closest point (UV=%g %g) %g %g %g \n",pnew.x(), pnew.y(), gp.y(), gp.z()); } else{ - printf("point not found in kdtree \n"); - exit(1); + Msg::Error("Point not found in kdtree"); gp.setNoSuccess(); } #else @@ -2031,8 +2033,7 @@ GPoint GFaceCompound::pointInRemeshedOctree(double par1, double par2) const if (gp.succeeded()) return gp; else{ - printf("NOT found point with ANN %g %g \n", par1, par2); - exit(1); + Msg::Error("NOT found point with ANN %g %g", par1, par2); GPoint gp (30,30,30,this); gp.setNoSuccess(); return gp; @@ -2882,7 +2883,7 @@ GPoint GFaceCompound::intersectionWithCircle(const SVector3 &n1, const SVector3 } GPoint pp(0); pp.setNoSuccess(); - Msg::Debug("ARGG no success intersection circle"); //exit(1); + Msg::Debug("ARGG no success intersection circle"); return pp; } diff --git a/Geo/GModelFactory.cpp b/Geo/GModelFactory.cpp index 0cd2d3692c7474cf1be4396e7e1cfe8c0ddedef2..76915970b710b5db241712e6ef74eb638e2b936a 100644 --- a/Geo/GModelFactory.cpp +++ b/Geo/GModelFactory.cpp @@ -286,12 +286,14 @@ std::vector<GFace *> GeoFactory::addRuledFaces(GModel *gm, return faces; } -std::vector<GEntity*> GeoFactory::extrudeBoundaryLayer(GModel *gm, GEntity *e, int nbLayers, double hLayer, int dir, int view) +std::vector<GEntity*> GeoFactory::extrudeBoundaryLayer(GModel *gm, GEntity *e, + int nbLayers, double hLayer, + int dir, int view) { ExtrudeParams *ep = new ExtrudeParams; ep->mesh.BoundaryLayerIndex = dir; - ep->mesh.ViewIndex = view;//view -5 for centerline based extrude + ep->mesh.ViewIndex = view; //view -5 for centerline based extrude ep->mesh.NbLayer = 1; //this may be more general for defining different layers ep->mesh.hLayer.clear(); ep->mesh.hLayer.push_back(hLayer); @@ -310,6 +312,8 @@ std::vector<GEntity*> GeoFactory::extrudeBoundaryLayer(GModel *gm, GEntity *e, i double A0=0., A1=0., A2=0.; double X0=0., X1=0., X2=0.,alpha=0.; + std::vector<GEntity*> extrudedEntities; + //extrude shape dans geo.cpp Shape shape; if(e->dim() == 0){ @@ -329,8 +333,8 @@ std::vector<GEntity*> GeoFactory::extrudeBoundaryLayer(GModel *gm, GEntity *e, i ((GFace*)e)->meshAttributes.extrude = ep; Surface *s = FindSurface(e->tag()); if(!s) { - printf("surface %d NOT found \n", e->tag()); - exit(1); + Msg::Error("Surface %d not found", e->tag()); + return extrudedEntities; } shape.Num = s->Num; shape.Type = s->Typ; @@ -352,8 +356,6 @@ std::vector<GEntity*> GeoFactory::extrudeBoundaryLayer(GModel *gm, GEntity *e, i //return the new created entity int nbout = List_Nbr(list_out); - std::vector<GEntity*> extrudedEntities; - //GEntity *newEnt =0; if(e->dim()==1){ Shape e; Shape s; diff --git a/Geo/GModelIO_Mesh.cpp b/Geo/GModelIO_Mesh.cpp index aa29cbba7af3e0411e7ff694dba739997a4076bb..56898ca1994b927f7dc1ed72ac6db156b6c2a89b 100644 --- a/Geo/GModelIO_Mesh.cpp +++ b/Geo/GModelIO_Mesh.cpp @@ -641,59 +641,33 @@ int GModel::readMSH(const std::string &name) elements[i].clear(); std::map<int, MElement* >::iterator ite; - for (ite = elems.begin(); ite != elems.end(); ite++) - { - int num = ite->first; - MElement *e = ite->second; - if (parents.find(num) == parents.end()) - { - int reg; - - if (CTX::instance()->mesh.switchElementTags) { - reg = elemphy[num]; - } - else - { - reg = elemreg[num]; - } - - switch (e->getType()) - { - case TYPE_PNT : - elements[0][reg].push_back(e); - break; - case TYPE_LIN : - elements[1][reg].push_back(e); - break; - case TYPE_TRI : - elements[2][reg].push_back(e); - break; - case TYPE_QUA : - elements[3][reg].push_back(e); - break; - case TYPE_TET : - elements[4][reg].push_back(e); - break; - case TYPE_HEX : - elements[5][reg].push_back(e); - break; - case TYPE_PRI : - elements[6][reg].push_back(e); - break; - case TYPE_PYR : - elements[7][reg].push_back(e); - break; - case TYPE_POLYG : - elements[8][reg].push_back(e); - break; - case TYPE_POLYH : - elements[9][reg].push_back(e); - break; - default : - Msg::Error("Wrong type of element"); - exit(1); - } - } + for (ite = elems.begin(); ite != elems.end(); ite++){ + int num = ite->first; + MElement *e = ite->second; + if (parents.find(num) == parents.end()){ + int reg; + if (CTX::instance()->mesh.switchElementTags) { + reg = elemphy[num]; + } + else{ + reg = elemreg[num]; + } + switch (e->getType()){ + case TYPE_PNT : elements[0][reg].push_back(e); break; + case TYPE_LIN : elements[1][reg].push_back(e); break; + case TYPE_TRI : elements[2][reg].push_back(e); break; + case TYPE_QUA : elements[3][reg].push_back(e); break; + case TYPE_TET : elements[4][reg].push_back(e); break; + case TYPE_HEX : elements[5][reg].push_back(e); break; + case TYPE_PRI : elements[6][reg].push_back(e); break; + case TYPE_PYR : elements[7][reg].push_back(e); break; + case TYPE_POLYG : elements[8][reg].push_back(e); break; + case TYPE_POLYH : elements[9][reg].push_back(e); break; + default : + Msg::Error("Wrong type of element"); + return false; + } + } } #endif } diff --git a/Geo/GRegionCompound.cpp b/Geo/GRegionCompound.cpp index 084216e1012ca0a1f3a3ff7bee8e576e5183da53..d77d2df50b94b06e2f4a70eb5639b55b0e487a25 100644 --- a/Geo/GRegionCompound.cpp +++ b/Geo/GRegionCompound.cpp @@ -15,11 +15,11 @@ GRegionCompound::GRegionCompound(GModel *m, int tag, std::vector<GRegion*> &compound) : GRegion(m, tag), _compound(compound) { - + for (unsigned int i = 0; i < _compound.size(); i++){ if(!_compound[i]){ - Msg::Error("Incorrect region in compound region %d\n", tag); - Msg::Exit(1); + Msg::Error("Incorrect region in compound region %d", tag); + return; } } for (unsigned int i = 0; i < _compound.size(); i++) @@ -42,18 +42,18 @@ void GRegionCompound::getBoundingFaces() for ( ; ite != ed.end(); ++ite){ _touched.insert(*ite); } - } + } it = _compound.begin(); for ( ; it != _compound.end(); ++it){ std::list<GFace*> ed = (*it)->faces(); std::list<GFace*> :: iterator ite = ed.begin(); for ( ; ite != ed.end() ; ++ite){ - if (!(*ite)->degenerate(0) && _touched.count(*ite) == 1) { + if (!(*ite)->degenerate(0) && _touched.count(*ite) == 1) { _unique.insert(*ite); } - } - } - + } + } + std::set<GFace*>::iterator itf = _unique.begin(); for ( ; itf != _unique.end(); ++itf){ printf("Compound Volume %d face %d \n", tag(), (*itf)->tag()); @@ -85,4 +85,4 @@ SVector3 GRegionCompound::firstDer(double par) const { Msg::Error("Cannot evaluate firstDeriv on GRegionCompound"); return SVector3(); -} +} diff --git a/Geo/MVertex.cpp b/Geo/MVertex.cpp index 2730f10aeed0ce2f6486ee8d95f9c7c41c7916e0..454573dc4b69f7bd92a28b215ff28f80ae2b1a6f 100644 --- a/Geo/MVertex.cpp +++ b/Geo/MVertex.cpp @@ -39,7 +39,7 @@ double angle3Vertices(MVertex *p1, MVertex *p2, MVertex *p3) SVector3 c = crossprod(a, b); double sinA = c.norm(); double cosA = dot(a, b); - return atan2 (sinA, cosA); + return atan2 (sinA, cosA); } MVertex::MVertex(double x, double y, double z, GEntity *ge, int num) @@ -59,10 +59,10 @@ MVertex::MVertex(double x, double y, double z, GEntity *ge, int num) } void MVertex::forceNum(int num) -{ +{ #pragma omp critical { - _num = num; + _num = num; _globalNum = std::max(_globalNum, _num); } } @@ -74,7 +74,7 @@ void MVertex::writeMSH(FILE *fp, bool binary, bool saveParametric, double scalin int myDim = 0, myTag = 0; if(saveParametric){ if(onWhat()){ - myDim = onWhat()->dim(); + myDim = onWhat()->dim(); myTag = onWhat()->tag(); } else @@ -83,10 +83,10 @@ void MVertex::writeMSH(FILE *fp, bool binary, bool saveParametric, double scalin if(!binary){ if(!saveParametric) - fprintf(fp, "%d %.16g %.16g %.16g\n", _index, x() * scalingFactor, - y() * scalingFactor, z() * scalingFactor); + fprintf(fp, "%d %.16g %.16g %.16g\n", _index, x() * scalingFactor, + y() * scalingFactor, z() * scalingFactor); else - fprintf(fp, "%d %.16g %.16g %.16g %d %d", _index, x() * scalingFactor, + fprintf(fp, "%d %.16g %.16g %.16g %d %d", _index, x() * scalingFactor, y() * scalingFactor, z() * scalingFactor, myDim, myTag); } else{ @@ -104,7 +104,7 @@ void MVertex::writeMSH(FILE *fp, bool binary, bool saveParametric, double scalin double _u; getParameter(0, _u); if(!binary) - fprintf(fp, " %.16g\n", _u); + fprintf(fp, " %.16g\n", _u); else fwrite(&_u, sizeof(double), 1, fp); } @@ -121,7 +121,7 @@ void MVertex::writeMSH(FILE *fp, bool binary, bool saveParametric, double scalin } else if(!binary) - fprintf(fp, "\n"); + fprintf(fp, "\n"); } } @@ -150,7 +150,7 @@ void MVertex::writeUNV(FILE *fp, double scalingFactor) fprintf(fp, "%10d%10d%10d%10d\n", _index, coord_sys, displacement_coord_sys, color); // hack to print the numbers with "D+XX" exponents char tmp[128]; - sprintf(tmp, "%25.16E%25.16E%25.16E\n", x() * scalingFactor, + sprintf(tmp, "%25.16E%25.16E%25.16E\n", x() * scalingFactor, y() * scalingFactor, z() * scalingFactor); for(unsigned int i = 0; i < strlen(tmp); i++) if(tmp[i] == 'E') tmp[i] = 'D'; fprintf(fp, "%s", tmp); @@ -176,8 +176,8 @@ void MVertex::writeMESH(FILE *fp, double scalingFactor) { if(_index < 0) return; // negative index vertices are never saved - fprintf(fp, " %20.14G %20.14G %20.14G %d\n", - x() * scalingFactor, y() * scalingFactor, z() * scalingFactor, + fprintf(fp, " %20.14G %20.14G %20.14G %d\n", + x() * scalingFactor, y() * scalingFactor, z() * scalingFactor, _ge ? _ge->tag() : 0); } @@ -222,12 +222,12 @@ void MVertex::writeBDF(FILE *fp, int format, double scalingFactor) double_to_char8(x1, xs); double_to_char8(y1, ys); double_to_char8(z1, zs); fprintf(fp, "GRID,%d,%d,%s,%s,%s\n", _index, 0, xs, ys, zs); } - else if(format == 1){ + else if(format == 1){ // small field format (8 char par field, 10 per line) double_to_char8(x1, xs); double_to_char8(y1, ys); double_to_char8(z1, zs); fprintf(fp, "GRID %-8d%-8d%-8s%-8s%-8s\n", _index, 0, xs, ys, zs); } - else{ + else{ // large field format (8 char first/last field, 16 char middle, 6 per line) fprintf(fp, "GRID* %-16d%-16d%-16.9G%-16.9G*N%-6d\n", _index, 0, x1, y1, _index); fprintf(fp, "*N%-6d%-16.9G\n", _index, z1); @@ -250,7 +250,7 @@ void MVertex::writeDIFF(FILE *fp, bool binary, double scalingFactor) _index, x() * scalingFactor, y() * scalingFactor, z() * scalingFactor); } -std::set<MVertex*, MVertexLessThanLexicographic>::iterator +std::set<MVertex*, MVertexLessThanLexicographic>::iterator MVertex::linearSearch(std::set<MVertex*, MVertexLessThanLexicographic> &pos) { for(std::set<MVertex*, MVertexLessThanLexicographic>::iterator it = pos.begin(); @@ -311,7 +311,7 @@ static void getAllParameters(MVertex *v, GFace *gf, std::vector<SPoint2> ¶ms } } -bool reparamMeshEdgeOnFace(MVertex *v1, MVertex *v2, GFace *gf, +bool reparamMeshEdgeOnFace(MVertex *v1, MVertex *v2, GFace *gf, SPoint2 ¶m1, SPoint2 ¶m2) { std::vector<SPoint2> p1, p2; @@ -323,33 +323,33 @@ bool reparamMeshEdgeOnFace(MVertex *v1, MVertex *v2, GFace *gf, return true; } else if (p1.size() == 1 && p2.size() == 2){ - double d1 = + double d1 = (p1[0].x() - p2[0].x()) * (p1[0].x() - p2[0].x()) + (p1[0].y() - p2[0].y()) * (p1[0].y() - p2[0].y()); - double d2 = + double d2 = (p1[0].x() - p2[1].x()) * (p1[0].x() - p2[1].x()) + (p1[0].y() - p2[1].y()) * (p1[0].y() - p2[1].y()); param1 = p1[0]; param2 = d2 < d1 ? p2[1] : p2[0]; return true; - } + } else if (p2.size() == 1 && p1.size() == 2){ - double d1 = + double d1 = (p2[0].x() - p1[0].x()) * (p2[0].x() - p1[0].x()) + (p2[0].y() - p1[0].y()) * (p2[0].y() - p1[0].y()); - double d2 = + double d2 = (p2[0].x() - p1[1].x()) * (p2[0].x() - p1[1].x()) + (p2[0].y() - p1[1].y()) * (p2[0].y() - p1[1].y()); param1 = d2 < d1 ? p1[1] : p1[0]; param2 = p2[0]; return true; - } + } else if(p1.size() > 1 && p2.size() > 1){ param1 = p1[0]; param2 = p2[0]; printf("NO WAY : TWO VERTICES ON THE SEAM, CANNOT CHOOSE\n"); - + // shout, both vertices are on seams return false; } @@ -373,8 +373,8 @@ bool reparamMeshVertexOnFace(MVertex *v, const GFace *gf, SPoint2 ¶m, return true; } - if(v->onWhat()->geomType() == GEntity::DiscreteCurve || - v->onWhat()->geomType() == GEntity::BoundaryLayerCurve){ + if(v->onWhat()->geomType() == GEntity::DiscreteCurve || + v->onWhat()->geomType() == GEntity::BoundaryLayerCurve){ param = gf->parFromPoint(SPoint3(v->x(), v->y(), v->z()), onSurface); return true; } @@ -397,9 +397,9 @@ bool reparamMeshVertexOnFace(MVertex *v, const GFace *gf, SPoint2 ¶m, v->getParameter(0, t); param = ge->reparamOnFace(gf, t, 1); if(!v->getParameter(0,t)) { - Msg::Error("vertex v %p not MedgeVertex", v); - Msg::Exit(1); - //param = gf->parFromPoint(SPoint3(v->x(), v->y(), v->z()), onSurface); + Msg::Error("Vertex %p not MEdgeVertex", v); + return false; + //param = gf->parFromPoint(SPoint3(v->x(), v->y(), v->z()), onSurface); } // shout, we are on a seam @@ -433,7 +433,7 @@ bool reparamMeshVertexOnEdge( MVertex *v, const GEdge *ge, double ¶m) if(!ok || param == 1.e6) param = ge->parFromPoint(SPoint3(v->x(), v->y(), v->z())); - + if(param < 1.e6) return true; return false; } diff --git a/Mesh/CenterlineField.cpp b/Mesh/CenterlineField.cpp index 2bc4531fb94d957b16689bdac74f87e14c2decc7..cb48b127b2bbeb2ceebc5a260e63e1055e4a8e91 100644 --- a/Mesh/CenterlineField.cpp +++ b/Mesh/CenterlineField.cpp @@ -108,7 +108,10 @@ static void orderMLines(std::vector<MLine*> &lines, MVertex *vB, MVertex *vE) else{ MVertex *v = (boundv.rbegin())->first; if (v == vB) firstLine = (boundv.rbegin())->second; - else{ Msg::Error("begin vertex not found for branch"); exit(1);} + else{ + Msg::Error("begin vertex not found for branch"); + return; + } } for (std::list<MLine*>::iterator it = segments.begin(); it != segments.end(); ++it){ @@ -371,7 +374,7 @@ void Centerline::importFile(std::string fileName) if(triangles.empty()){ Msg::Error("Current GModel has no triangles ..."); - exit(1); + return; } mod = new GModel(); diff --git a/Mesh/meshGFaceExtruded.cpp b/Mesh/meshGFaceExtruded.cpp index 2b2b2de0e529da8de2211f4d3a149a90aeef8b3c..a7ed6446bd45e7b87948355d5b914a45088e8a3b 100644 --- a/Mesh/meshGFaceExtruded.cpp +++ b/Mesh/meshGFaceExtruded.cpp @@ -262,7 +262,6 @@ int MeshExtrudedSurface(GFace *gf, GFace *from = gf->model()->getFaceByTag(std::abs(ep->geo.Source)); if(!from){ Msg::Error("Unknown source surface %d for extrusion", ep->geo.Source); - exit(1); return 0; } else if(from->geomType() != GEntity::DiscreteSurface && diff --git a/Mesh/meshGFaceOptimize.cpp b/Mesh/meshGFaceOptimize.cpp index 166f13183ef2124b242175cf394dc0ebd5a8e235..62c33b94e61557cdbddf09620387f0c4c38cef08 100644 --- a/Mesh/meshGFaceOptimize.cpp +++ b/Mesh/meshGFaceOptimize.cpp @@ -849,10 +849,13 @@ void createRegularMesh (GFace *gf, // printf("v1=%d v2=%d v3=%d v4=%d \n", v1->getNum(), v2->getNum(), v3->getNum(), v4->getNum()); // printf("c1=%g %g, c2=%g %g, c3=%g %g, c4=%g,%g \n", c1.x(),c1.y(),c2.x(),c2.y(),c3.x(),c3.y(),c4.x(),c4.y()); // printf("p1=%g %g, p2=%g %g, p3=%g %g, p4=%g,%g \n", p12.x(),p12.x(),p23.x(),p23.y(),p34.x(),p34.y(),p41.x(),p41.y()); - if (p12.x() && p12.y() == -1.0) {printf("wrong param -1 \n"); exit(1);} - if (p23.x() && p23.y() == -1.0) {printf("wrong param -1 \n"); exit(1);} - if (p34.x() && p34.y() == -1.0) {printf("wrong param -1 \n"); exit(1);} - if (p41.x() && p41.y() == -1.0) {printf("wrong param -1 \n"); exit(1);} + if ((p12.x() && p12.y() == -1.0) || + (p23.x() && p23.y() == -1.0) || + (p34.x() && p34.y() == -1.0) || + (p41.x() && p41.y() == -1.0)) { + Msg::Error("Wrong param -1"); + return; + } MVertex *vnew = createNewVertex (gf, SPoint2(Up,Vp)); tab[j+1][i+1] = vnew; @@ -1977,7 +1980,6 @@ int _edgeSwapQuadsForBetterQuality(GFace *gf) } if (rot1 != rot2){ Msg::Error("Quads are not oriented the same (in edgeSwapQuads opti)"); - //exit(1); return 0; } diff --git a/Mesh/meshGRegionExtruded.cpp b/Mesh/meshGRegionExtruded.cpp index ebc8875d66e8502f231c3e4ec4c97de53e04e6a5..c56da129fdbc2b084354717466f308deb90e6f5b 100644 --- a/Mesh/meshGRegionExtruded.cpp +++ b/Mesh/meshGRegionExtruded.cpp @@ -18,7 +18,7 @@ #include "GmshMessage.h" #include "QuadTriExtruded3D.h" -static void addTetrahedron(MVertex* v1, MVertex* v2, MVertex* v3, MVertex* v4, +static void addTetrahedron(MVertex* v1, MVertex* v2, MVertex* v3, MVertex* v4, GRegion *to) { to->tetrahedra.push_back(new MTetrahedron(v1, v2, v3, v4)); @@ -80,7 +80,7 @@ static void createHexPri(std::vector<MVertex*> &v, GRegion *to, MElement* source for(int i = 0; i < 4; i++) if(v[i] == v[i + 4]) dup[j++] = i; - + if(j == 2) { if(dup[0] == 0 && dup[1] == 1) addPrism(v[0], v[3], v[7], v[1], v[2], v[6], to); @@ -106,7 +106,7 @@ static void createTet(MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, GRegio addTetrahedron(v1, v2, v3, v4, to); } -static int getExtrudedVertices(MElement *ele, ExtrudeParams *ep, int j, int k, +static int getExtrudedVertices(MElement *ele, ExtrudeParams *ep, int j, int k, std::set<MVertex*, MVertexLessThanLexicographic> &pos, std::vector<MVertex*> &verts) { @@ -195,7 +195,7 @@ static void extrudeMesh(GFace *from, GRegion *to, } } -static void insertAllVertices(GRegion *gr, +static void insertAllVertices(GRegion *gr, std::set<MVertex*, MVertexLessThanLexicographic> &pos) { pos.insert(gr->mesh_vertices.begin(), gr->mesh_vertices.end()); @@ -217,8 +217,8 @@ static void insertAllVertices(GRegion *gr, } } -void meshGRegionExtruded::operator() (GRegion *gr) -{ +void meshGRegionExtruded::operator() (GRegion *gr) +{ gr->model()->setCurrentMeshEntity(gr); if(gr->geomType() == GEntity::DiscreteVolume) return; @@ -234,7 +234,7 @@ void meshGRegionExtruded::operator() (GRegion *gr) dem(gr); // build a set with all the vertices on the boundary of gr - double old_tol = MVertexLessThanLexicographic::tolerance; + double old_tol = MVertexLessThanLexicographic::tolerance; MVertexLessThanLexicographic::tolerance = 1.e-12 * CTX::instance()->lc; std::set<MVertex*, MVertexLessThanLexicographic> pos; insertAllVertices(gr, pos); @@ -243,7 +243,6 @@ void meshGRegionExtruded::operator() (GRegion *gr) GFace *from = gr->model()->getFaceByTag(std::abs(ep->geo.Source)); if(!from){ Msg::Error("Unknown source surface %d for extrusion", ep->geo.Source); - exit(1); return; } @@ -256,25 +255,25 @@ void meshGRegionExtruded::operator() (GRegion *gr) for(it = ep->mesh.Holes.begin(); it != ep->mesh.Holes.end(); it++) carveHole(gr, it->first, it->second.first, it->second.second); } - - MVertexLessThanLexicographic::tolerance = old_tol; + + MVertexLessThanLexicographic::tolerance = old_tol; } -static int edgeExists(MVertex *v1, MVertex *v2, +static int edgeExists(MVertex *v1, MVertex *v2, std::set<std::pair<MVertex*, MVertex*> > &edges) { std::pair<MVertex*, MVertex*> p(std::min(v1, v2), std::max(v1, v2)); return edges.count(p); } -static void createEdge(MVertex *v1, MVertex *v2, +static void createEdge(MVertex *v1, MVertex *v2, std::set<std::pair<MVertex*, MVertex*> > &edges) { std::pair<MVertex*, MVertex*> p(std::min(v1, v2), std::max(v1, v2)); edges.insert(p); } -static void deleteEdge(MVertex *v1, MVertex *v2, +static void deleteEdge(MVertex *v1, MVertex *v2, std::set<std::pair<MVertex*, MVertex*> > &edges) { std::pair<MVertex*, MVertex*> p(std::min(v1, v2), std::max(v1, v2)); @@ -333,7 +332,7 @@ static void phase2(GRegion *gr, std::vector<MVertex*> v; if(getExtrudedVertices(from->triangles[i], ep, j, k, pos, v) == 6){ if(edgeExists(v[3], v[1], edges) && - edgeExists(v[4], v[2], edges) && + edgeExists(v[4], v[2], edges) && edgeExists(v[0], v[5], edges)) { swap++; if(!edgeExists(v[3], v[1], edges_swap)) { @@ -383,7 +382,7 @@ static void phase2(GRegion *gr, } } } - + // create tets static void phase3(GRegion *gr, std::set<MVertex*, MVertexLessThanLexicographic> &pos, @@ -453,12 +452,12 @@ int SubdivideExtrudedMesh(GModel *m) // create a vector of quadToTri regions that have NOT been meshed // yet std::vector<GRegion*> regions, regions_quadToTri; - double old_tol = MVertexLessThanLexicographic::tolerance; + double old_tol = MVertexLessThanLexicographic::tolerance; MVertexLessThanLexicographic::tolerance = 1.e-12 * CTX::instance()->lc; std::set<MVertex*, MVertexLessThanLexicographic> pos; for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++){ ExtrudeParams *ep = (*it)->meshAttributes.extrude; - if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY && + if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY && !ep->mesh.Recombine){ regions.push_back(*it); insertAllVertices(*it, pos); @@ -498,13 +497,13 @@ int SubdivideExtrudedMesh(GModel *m) for(unsigned int i = 0; i < regions.size(); i++){ GRegion *gr = regions[i]; - for(unsigned int i = 0; i < gr->tetrahedra.size(); i++) + for(unsigned int i = 0; i < gr->tetrahedra.size(); i++) delete gr->tetrahedra[i]; gr->tetrahedra.clear(); - for(unsigned int i = 0; i < gr->hexahedra.size(); i++) + for(unsigned int i = 0; i < gr->hexahedra.size(); i++) delete gr->hexahedra[i]; gr->hexahedra.clear(); - for(unsigned int i = 0; i < gr->prisms.size(); i++) + for(unsigned int i = 0; i < gr->prisms.size(); i++) delete gr->prisms[i]; gr->prisms.clear(); for(unsigned int i = 0; i < gr->pyramids.size(); i++) @@ -516,21 +515,21 @@ int SubdivideExtrudedMesh(GModel *m) std::list<GFace*> faces = gr->faces(); for(std::list<GFace*>::iterator it = faces.begin(); it != faces.end(); it++){ ExtrudeParams *ep = (*it)->meshAttributes.extrude; - if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY && + if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY && !ep->mesh.Recombine){ GFace *gf = *it; Msg::Info("Remeshing surface %d", gf->tag()); - for(unsigned int i = 0; i < gf->triangles.size(); i++) + for(unsigned int i = 0; i < gf->triangles.size(); i++) delete gf->triangles[i]; gf->triangles.clear(); - for(unsigned int i = 0; i < gf->quadrangles.size(); i++) + for(unsigned int i = 0; i < gf->quadrangles.size(); i++) delete gf->quadrangles[i]; gf->quadrangles.clear(); MeshExtrudedSurface(gf, &edges); } } } - + // now mesh the QuadToTri regions. Everything can be done locally // for each quadToTri region, but still use edge set from above just // to make sure laterals get remeshed properly ( @@ -566,6 +565,6 @@ int SubdivideExtrudedMesh(GModel *m) } } - MVertexLessThanLexicographic::tolerance = old_tol; + MVertexLessThanLexicographic::tolerance = old_tol; return 1; } diff --git a/Mesh/multiscalePartition.cpp b/Mesh/multiscalePartition.cpp index 5bf57431a80b885d4c6114d2502eff72f6a3e551..a34440a5d06d9fcb4f30af247b812f84f9a9b659 100644 --- a/Mesh/multiscalePartition.cpp +++ b/Mesh/multiscalePartition.cpp @@ -369,7 +369,7 @@ void multiscalePartition::partition(partitionLevel & level, int nbParts, if (genus < 0) { Msg::Error("Genus partition is negative G=%d!", genus); - exit(1); + return; } if (genus != 0 ){ diff --git a/Plugin/GSHHS.cpp b/Plugin/GSHHS.cpp index 2888c6993946364d7dd33f4a8e5c3086337f12c7..2e757edb2cfdea29ff810d679e3529d3c81a466f 100644 --- a/Plugin/GSHHS.cpp +++ b/Plugin/GSHHS.cpp @@ -60,7 +60,7 @@ public: return false; point[2] = 0; ipoint++; - if(fscanf(fp, "%le %le", &point[0], &point[1]) != 2) + if(fscanf(fp, "%le %le", &point[0], &point[1]) != 2) Msg::Error("gshhs: Error reading loops2 file."); return true; } @@ -96,11 +96,11 @@ public: * For use with version 1.6 of GSHHS which now has WDBII * borders and rivers. */ -#define GSHHS_DATA_VERSION 6 // For v1.5 data set +#define GSHHS_DATA_VERSION 6 // For v1.5 data set //define GSHHS_PROG_VERSION "1.9" -#define GSHHS_SCL 1.0e-6 // COnvert micro-degrees to degrees +#define GSHHS_SCL 1.0e-6 // COnvert micro-degrees to degrees inline unsigned int swabi4(unsigned int i4) - { // For byte swapping on little-endian systems (GSHHS is defined to be bigendian) + { // For byte swapping on little-endian systems (GSHHS is defined to be bigendian) return (((i4) >> 24) + (((i4) >> 8) & 65280) + (((i4) & 65280) << 8) + (((i4) & 255) << 24)); } class POINT { /* Each lon, lat pair is stored in micro-degrees in 4-byte integer format */ @@ -187,7 +187,7 @@ public: return false; if (fread ((void *)&p, (size_t)sizeof(POINT), (size_t)1, fp) != 1) { Msg::Error("gshhs: Error reading gshhs file."); - exit(1); + return false; } if (flip) { p.x = swabi4 ((unsigned int)p.x); @@ -248,7 +248,7 @@ public: } }; - // ************** UTM ************** + // ************** UTM ************** class coordinate_utm : public coordinate_system{ int zone; coordinate_lonlat ll_conv; @@ -265,7 +265,7 @@ public: return Ap * lat + Bp * sin(2 * lat) + Cp * sin(4 * lat) + Dp * sin(6 * lat) + Ep; } - void from_cartesian(const SPoint3 xyz,SPoint3 &utm) + void from_cartesian(const SPoint3 xyz,SPoint3 &utm) { ll_conv.from_cartesian(xyz,ll); double S = meridionalarc(ll.x(),ll.y()); @@ -281,10 +281,10 @@ public: double p2 = p * p; double p3 = p * p2; double p4 = p2 * p2; - utm.setPosition(k0 * nu * clat * p + (k0 * nu * clat3 / 6) + utm.setPosition(k0 * nu * clat * p + (k0 * nu * clat3 / 6) * (1 - tlat2 + ep2 * clat2) * p3 + 5e5, - S * k0 + k0 * nu * slat * clat / 2 * p2 - + k0 * nu * slat * clat3 / 24 + S * k0 + k0 * nu * slat * clat / 2 * p2 + + k0 * nu * slat * clat3 / 24 * (5 - tlat2 + 9 * ep2 * clat2 + 4 * ep4 * clat4) * p4, 0); } @@ -315,8 +315,8 @@ public: (5 - 2 * c1 + 28 * t1 - 3 * c12 + 8 * ep2 + 24 * t12) * d5 / 120) / cfp, - fp - n1 * sfp / cfp / r1 - * (d2 / 2 - (5 + 3 * t1 + 10 * c1 - 4 * c12 - 9 * ep2) * d4 / 24 + fp - n1 * sfp / cfp / r1 + * (d2 / 2 - (5 + 3 * t1 + 10 * c1 - 4 * c12 - 9 * ep2) * d4 / 24 + (61 + 90 * t1 + 298 * c1 + 45 * t12 - 3 * c12 - 252 * ep2) * d6 / 720), 0); ll_conv.to_cartesian(ll,xyz); @@ -788,7 +788,7 @@ public: { first_point_in_attractor = ip; } - void new_surface() + void new_surface() { surface_buff.str(""); surface_buff << "Plane Surface( IS + " << is++ << " ) = { "; @@ -840,7 +840,7 @@ public: loop_buff << "Point ( IP + " << ip++ << " ) = {" << stereo. x() << ", " << stereo.y() << ", " << 0 << " };\n"; } - void end_loop(bool closed) + void end_loop(bool closed) { if(ip - first_point_in_loop > 3) { loop_buff<<"LoopStart"<<il<<" = IP + "<< first_point_in_loop<<";\n"; @@ -897,7 +897,7 @@ public: PView *execute(PView *); }; -// ************** MAIN PLUGIN ************** +// ************** MAIN PLUGIN ************** StringXNumber GSHHSOptions_Number[] = { {GMSH_FULLRC, "iField", NULL, -1.}, {GMSH_FULLRC, "UTMZone", NULL, 0}, @@ -924,7 +924,7 @@ extern "C" std::string GMSH_GSHHSPlugin::getHelp() const { - return + return "Plugin(GSHHS) read different kind of contour lines data " "and write a .geo file on the surface of a sphere (the Earth).\n\n" "The principal application is to load GSHHS data\n (see " @@ -1076,7 +1076,7 @@ PView *GMSH_GSHHSPlugin::execute(PView * v) for(loops::iterator il=ll.begin();il!=ll.end();il++){ box b(point(-radius,-radius,-radius,0.),point(radius,radius,radius,0.)); loop_fill_box(&*il,b); - while(false + while(false || loop_check_small_angles(&*il) || loop_check_close_points_self(&*il,b) || loop_check_intersections(&*il,b) diff --git a/Solver/multiscaleLaplace.cpp b/Solver/multiscaleLaplace.cpp index 83466b6c117b36882157552e7aa5424a5ecd7be8..eecb7b1eb054bb1bc66eb63536fc373c68a0ba07 100644 --- a/Solver/multiscaleLaplace.cpp +++ b/Solver/multiscaleLaplace.cpp @@ -1074,9 +1074,9 @@ void multiscaleLaplace::cutElems(std::vector<MElement *> &elements) connected_left_right(left, right); if (left.size() == 0 || right.size() == 0) { - printf("KO size left=%d, right=%d not good (zero elems)\n", - (int) left.size(), (int) right.size() ); - exit(1); + Msg::Error("KO size left=%d, right=%d not good (zero elems)", + (int) left.size(), (int) right.size() ); + return; } elements.clear(); @@ -1086,7 +1086,6 @@ void multiscaleLaplace::cutElems(std::vector<MElement *> &elements) printLevel ("Rootcut-left.msh",left,0,2.2); printLevel ("Rootcut-right.msh",right,0,2.2); printLevel ("Rootcut-all.msh",elements, 0,2.2); - //exit(1); } void multiscaleLaplace::splitElems(std::vector<MElement *> &elements) @@ -1115,7 +1114,7 @@ void multiscaleLaplace::splitElems(std::vector<MElement *> &elements) if ( elements.size() != left.size()+right.size()) { Msg::Error("Cutting laplace wrong nb elements (%d) != left + right (%d)", elements.size(), left.size()+right.size()); - exit(1); + return; } elements.clear();