From b19eadb4341c9f4391c33438586179301868fbcf Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 16 Jan 2010 15:07:05 +0000 Subject: [PATCH] pretty please do not just "throw;" when you don't know what to do + constify MElement some more --- Fltk/menuWindow.cpp | 2 +- Fltk/menuWindow.h | 2 -- Geo/GFaceCompound.cpp | 5 ++++- Geo/MElement.cpp | 2 +- Geo/MElement.h | 33 +++++++++++++++++++++------------ Geo/MElementCut.h | 4 ++-- Geo/MHexahedron.cpp | 39 ++++++++++++++++++++++++--------------- Geo/MHexahedron.h | 2 +- Geo/MLine.h | 7 +++++-- Geo/MPoint.h | 2 +- Geo/MPrism.h | 2 +- Geo/MPyramid.h | 2 +- Geo/MQuadrangle.h | 9 +++++---- Geo/MTetrahedron.cpp | 14 ++++++++------ Geo/MTetrahedron.h | 4 ++-- Geo/MTriangle.h | 9 +++++---- 16 files changed, 82 insertions(+), 56 deletions(-) diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp index 9f791ddaad..5040dacc5f 100644 --- a/Fltk/menuWindow.cpp +++ b/Fltk/menuWindow.cpp @@ -141,7 +141,7 @@ static void file_merge_cb(Fl_Widget *w, void *data) FlGui::instance()->menu->setContext(menu_post, 0); } -void file_open_recent_cb(Fl_Widget *w, void *data) +static void file_open_recent_cb(Fl_Widget *w, void *data) { std::string str((const char*)data); diff --git a/Fltk/menuWindow.h b/Fltk/menuWindow.h index 6b8ca7efc8..b91bf476d6 100644 --- a/Fltk/menuWindow.h +++ b/Fltk/menuWindow.h @@ -72,7 +72,6 @@ class menuWindow{ std::vector<popupButton*> popup; std::vector<popupButton*> popup2; std::vector<char*> label, label2; - public: menuWindow(); void setContext(contextItem *menu_asked, int flag); @@ -90,6 +89,5 @@ void geometry_reload_cb(Fl_Widget *w, void *data); void mesh_1d_cb(Fl_Widget *w, void *data); void mesh_2d_cb(Fl_Widget *w, void *data); void mesh_3d_cb(Fl_Widget *w, void *data); -void file_open_recent_cb(Fl_Widget *w, void *data); #endif diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp index 5c67c928c7..31d57fa222 100644 --- a/Geo/GFaceCompound.cpp +++ b/Geo/GFaceCompound.cpp @@ -964,7 +964,10 @@ void GFaceCompound::parametrize(iterationStep step, typeOfMapping tom) const } } } - else throw; + else{ + Msg::Error("Unknown type of parametrization"); + return; + } std::list<GFace*>::const_iterator it = _compound.begin(); for( ; it != _compound.end(); ++it){ diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp index 4dad3a651f..b29d77a43b 100644 --- a/Geo/MElement.cpp +++ b/Geo/MElement.cpp @@ -72,7 +72,7 @@ void MElement::_getFaceRep(MVertex *v0, MVertex *v1, MVertex *v2, for(int i = 0; i < 3; i++) n[i] = normal; } -char MElement::getVisibility() +char MElement::getVisibility() const { if(CTX::instance()->hideUnselected && _visible < 2) return false; return _visible; diff --git a/Geo/MElement.h b/Geo/MElement.h index 2b6c803f7d..71df81d183 100644 --- a/Geo/MElement.h +++ b/Geo/MElement.h @@ -50,32 +50,35 @@ class MElement static void resetGlobalNumber(){ _globalNum = 0; } // set/get the tolerance for isInside() test - static void setTolerance (const double tol){ _isInsideTolerance = tol; } - static double getTolerance () { return _isInsideTolerance; } + static void setTolerance(const double tol){ _isInsideTolerance = tol; } + static double getTolerance() { return _isInsideTolerance; } // return the tag of the element - virtual int getNum(){ return _num; } + virtual int getNum() const { return _num; } // return the geometrical dimension of the element - virtual int getDim() = 0; + virtual int getDim() const = 0; // return the polynomial order the element virtual int getPolynomialOrder() const { return 1; } // get/set the partition to which the element belongs - virtual int getPartition(){ return _partition; } + virtual int getPartition() const { return _partition; } virtual void setPartition(int num){_partition = (short)num; } // get/set the visibility flag - virtual char getVisibility(); + virtual char getVisibility() const; virtual void setVisibility(char val){ _visible = val; } // get the vertices virtual int getNumVertices() const = 0; virtual MVertex *getVertex(int num) = 0; + // give an MVertex as input and get its local number - virtual void getVertexInfo (const MVertex * vertex, int &ithVertex) const - {throw;} + virtual void getVertexInfo(const MVertex * vertex, int &ithVertex) const + { + Msg::Error("Vertex information not available for this element"); + } // get the vertex using the I-deas UNV ordering virtual MVertex *getVertexUNV(int num){ return getVertex(num); } @@ -109,9 +112,12 @@ class MElement // get the edges virtual int getNumEdges() = 0; virtual MEdge getEdge(int num) = 0; + // give an MEdge as input and get its local number and sign - virtual void getEdgeInfo (const MEdge & edge, int &ithEdge, int &sign) const - {throw;} + virtual void getEdgeInfo(const MEdge & edge, int &ithEdge, int &sign) const + { + Msg::Error("Edge information not available for this element"); + } // get an edge representation for drawing virtual int getNumEdgesRep() = 0; @@ -126,9 +132,12 @@ class MElement // get the faces virtual int getNumFaces() = 0; virtual MFace getFace(int num) = 0; + // give an MFace as input and get its local number, sign and rotation - virtual void getFaceInfo (const MFace & face, int &ithFace, int &sign, int &rot)const - {throw;} + virtual void getFaceInfo(const MFace & face, int &ithFace, int &sign, int &rot) const + { + Msg::Error("Face information not available for this element"); + } // get a face representation for drawing virtual int getNumFacesRep() = 0; diff --git a/Geo/MElementCut.h b/Geo/MElementCut.h index c4a59ceb09..7d0d2a82ea 100644 --- a/Geo/MElementCut.h +++ b/Geo/MElementCut.h @@ -55,7 +55,7 @@ class MPolyhedron : public MElement { delete _parts[i]; if(_intpt) delete [] _intpt; } - virtual int getDim() { return 3; } + virtual int getDim() const { return 3; } virtual int getNumVertices() const { return _vertices.size() + _innerVertices.size(); } virtual int getNumVolumeVertices() const { return _innerVertices.size(); } virtual MVertex *getVertex(int num) @@ -170,7 +170,7 @@ class MPolygon : public MElement { delete _parts[i]; if(_intpt) delete [] _intpt; } - virtual int getDim(){ return 2; } + virtual int getDim() const { return 2; } virtual int getNumVertices() const { return _vertices.size() + _innerVertices.size(); } virtual int getNumFaceVertices() const { return _innerVertices.size(); } virtual MVertex *getVertex(int num) diff --git a/Geo/MHexahedron.cpp b/Geo/MHexahedron.cpp index 88adfc2c08..4575afb5c4 100644 --- a/Geo/MHexahedron.cpp +++ b/Geo/MHexahedron.cpp @@ -27,37 +27,46 @@ void MHexahedron::getIntegrationPoints(int pOrder, int *npts, IntPt **pts) *pts = getGQHPts(pOrder); } -void MHexahedron::getFaceInfo (const MFace & face, int &ithFace, int &sign, int &rot)const{ - for (ithFace=0;ithFace<6;ithFace++){ - MVertex *v0 = _v[faces_hexa(ithFace,0)]; - MVertex *v1 = _v[faces_hexa(ithFace,1)]; - MVertex *v2 = _v[faces_hexa(ithFace,2)]; - MVertex *v3 = _v[faces_hexa(ithFace,3)]; +void MHexahedron::getFaceInfo(const MFace &face, int &ithFace, int &sign, int &rot) const +{ + for (ithFace = 0; ithFace < 6; ithFace++){ + MVertex *v0 = _v[faces_hexa(ithFace, 0)]; + MVertex *v1 = _v[faces_hexa(ithFace, 1)]; + MVertex *v2 = _v[faces_hexa(ithFace, 2)]; + MVertex *v3 = _v[faces_hexa(ithFace, 3)]; - if (v0 == face.getVertex(0) && v1 == face.getVertex(1) && v2 == face.getVertex(2) && v3 == face.getVertex(3)){ + if (v0 == face.getVertex(0) && v1 == face.getVertex(1) && + v2 == face.getVertex(2) && v3 == face.getVertex(3)){ sign = 1; rot = 0; return; } - if (v0 == face.getVertex(1) && v1 == face.getVertex(2) && v3 == face.getVertex(3) && v2 == face.getVertex(0)){ + if (v0 == face.getVertex(1) && v1 == face.getVertex(2) && + v3 == face.getVertex(3) && v2 == face.getVertex(0)){ sign = 1; rot = 1; return; } - if (v0 == face.getVertex(2) && v3 == face.getVertex(3) && v1 == face.getVertex(0) && v2 == face.getVertex(1)){ + if (v0 == face.getVertex(2) && v3 == face.getVertex(3) && + v1 == face.getVertex(0) && v2 == face.getVertex(1)){ sign = 1; rot = 2; return; } - if (v0 == face.getVertex(3) && v3 == face.getVertex(0) && v1 == face.getVertex(1) && v2 == face.getVertex(2)){ + if (v0 == face.getVertex(3) && v3 == face.getVertex(0) && + v1 == face.getVertex(1) && v2 == face.getVertex(2)){ sign = 1; rot = 3; return; } - if (v0 == face.getVertex(0) && v1 == face.getVertex(3) && v2 == face.getVertex(2) && v3 == face.getVertex(1)){ + if (v0 == face.getVertex(0) && v1 == face.getVertex(3) && + v2 == face.getVertex(2) && v3 == face.getVertex(1)){ sign = -1; rot = 0; return; } - if (v0 == face.getVertex(3) && v1 == face.getVertex(2) && v2 == face.getVertex(1) && v3 == face.getVertex(0)){ + if (v0 == face.getVertex(3) && v1 == face.getVertex(2) && + v2 == face.getVertex(1) && v3 == face.getVertex(0)){ sign = -1; rot = 1; return; } - if (v0 == face.getVertex(2) && v1 == face.getVertex(1) && v2 == face.getVertex(0) && v3 == face.getVertex(3)){ + if (v0 == face.getVertex(2) && v1 == face.getVertex(1) && + v2 == face.getVertex(0) && v3 == face.getVertex(3)){ sign = -1; rot = 2; return; } - if (v0 == face.getVertex(1) && v1 == face.getVertex(0) && v2 == face.getVertex(3) && v3 == face.getVertex(2)){ + if (v0 == face.getVertex(1) && v1 == face.getVertex(0) && + v2 == face.getVertex(3) && v3 == face.getVertex(2)){ sign = -1; rot = 3; return; } } - throw; + Msg::Error("Could not get face information for hexahedron %d", getNum()); } diff --git a/Geo/MHexahedron.h b/Geo/MHexahedron.h index 6be76e7c8e..f22f579f5b 100644 --- a/Geo/MHexahedron.h +++ b/Geo/MHexahedron.h @@ -54,7 +54,7 @@ class MHexahedron : public MElement { for(int i = 0; i < 8; i++) _v[i] = v[i]; } ~MHexahedron(){} - virtual int getDim(){ return 3; } + virtual int getDim() const { return 3; } virtual int getNumVertices() const { return 8; } virtual MVertex *getVertex(int num){ return _v[num]; } virtual MVertex *getVertexMED(int num) diff --git a/Geo/MLine.h b/Geo/MLine.h index 7266b32e38..f38e00dcbd 100644 --- a/Geo/MLine.h +++ b/Geo/MLine.h @@ -34,10 +34,13 @@ class MLine : public MElement { for(int i = 0; i < 2; i++) _v[i] = v[i]; } ~MLine(){} - virtual int getDim(){ return 1; } + virtual int getDim() const { return 1; } virtual int getNumVertices() const { return 2; } virtual MVertex *getVertex(int num){ return _v[num]; } - virtual void getVertexInfo (const MVertex * vertex, int &ithVertex) const { ithVertex = _v[0] == vertex ? 0 : 1; } + virtual void getVertexInfo(const MVertex * vertex, int &ithVertex) const + { + ithVertex = _v[0] == vertex ? 0 : 1; + } virtual int getNumEdges(){ return 1; } virtual MEdge getEdge(int num){ return MEdge(_v[0], _v[1]); } virtual int getNumEdgesRep(){ return 1; } diff --git a/Geo/MPoint.h b/Geo/MPoint.h index 3098159e06..8d13e0f30a 100644 --- a/Geo/MPoint.h +++ b/Geo/MPoint.h @@ -27,7 +27,7 @@ class MPoint : public MElement { _v[0] = v[0]; } ~MPoint(){} - virtual int getDim(){ return 0; } + virtual int getDim() const { return 0; } virtual int getNumVertices() const { return 1; } virtual MVertex *getVertex(int num){ return _v[0]; } virtual int getNumEdges(){ return 0; } diff --git a/Geo/MPrism.h b/Geo/MPrism.h index 48152c6173..581dd4532e 100644 --- a/Geo/MPrism.h +++ b/Geo/MPrism.h @@ -60,7 +60,7 @@ class MPrism : public MElement { for(int i = 0; i < 6; i++) _v[i] = v[i]; } ~MPrism(){} - virtual int getDim(){ return 3; } + virtual int getDim() const { return 3; } virtual int getNumVertices() const { return 6; } virtual MVertex *getVertex(int num){ return _v[num]; } virtual MVertex *getVertexMED(int num) diff --git a/Geo/MPyramid.h b/Geo/MPyramid.h index f27c606c1c..c560d85df3 100644 --- a/Geo/MPyramid.h +++ b/Geo/MPyramid.h @@ -64,7 +64,7 @@ class MPyramid : public MElement { for(int i = 0; i < 5; i++) _v[i] = v[i]; } ~MPyramid(){} - virtual int getDim(){ return 3; } + virtual int getDim() const { return 3; } virtual int getNumVertices() const { return 5; } virtual MVertex *getVertex(int num){ return _v[num]; } virtual MVertex *getVertexMED(int num) diff --git a/Geo/MQuadrangle.h b/Geo/MQuadrangle.h index e4e5cbb373..a4c274f6d0 100644 --- a/Geo/MQuadrangle.h +++ b/Geo/MQuadrangle.h @@ -50,7 +50,7 @@ class MQuadrangle : public MElement { for(int i = 0; i < 4; i++) _v[i] = v[i]; } ~MQuadrangle(){} - virtual int getDim(){ return 2; } + virtual int getDim() const { return 2; } virtual int getNumVertices() const { return 4; } virtual MVertex *getVertex(int num){ return _v[num]; } virtual MVertex *getVertexMED(int num) @@ -68,8 +68,9 @@ class MQuadrangle : public MElement { { return MEdge(_v[edges_quad(num, 0)], _v[edges_quad(num, 1)]); } - virtual void getEdgeInfo (const MEdge & edge, int &ithEdge, int &sign) const { - for (ithEdge=0;ithEdge<4;ithEdge++){ + virtual void getEdgeInfo (const MEdge &edge, int &ithEdge, int &sign) const + { + for (ithEdge = 0; ithEdge < 4; ithEdge++){ const MVertex *v0 = _v[edges_quad(ithEdge, 0)]; const MVertex *v1 = _v[edges_quad(ithEdge, 1)]; if (v0 == edge.getVertex(0) && v1 == edge.getVertex(1)){ @@ -79,7 +80,7 @@ class MQuadrangle : public MElement { sign = -1; return; } } - throw; + Msg::Error("Could not get edge information for quadranglee %d", getNum()); } virtual int getNumEdgesRep(){ return 4; } virtual void getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n) diff --git a/Geo/MTetrahedron.cpp b/Geo/MTetrahedron.cpp index e79da9bb50..b78b9a02cf 100644 --- a/Geo/MTetrahedron.cpp +++ b/Geo/MTetrahedron.cpp @@ -254,11 +254,13 @@ void MTetrahedron::getIntegrationPoints(int pOrder, int *npts, IntPt **pts) *npts = getNGQTetPts(pOrder); *pts = getGQTetPts(pOrder); } -void MTetrahedron::getFaceInfo (const MFace & face, int &ithFace, int &sign, int &rot)const{ - for (ithFace=0;ithFace<4;ithFace++){ - MVertex *v0 = _v[faces_tetra(ithFace,0)]; - MVertex *v1 = _v[faces_tetra(ithFace,1)]; - MVertex *v2 = _v[faces_tetra(ithFace,2)]; + +void MTetrahedron::getFaceInfo(const MFace &face, int &ithFace, int &sign, int &rot) const +{ + for (ithFace = 0; ithFace < 4; ithFace++){ + MVertex *v0 = _v[faces_tetra(ithFace, 0)]; + MVertex *v1 = _v[faces_tetra(ithFace, 1)]; + MVertex *v2 = _v[faces_tetra(ithFace, 2)]; if (v0 == face.getVertex(0) && v1 == face.getVertex(1) && v2 == face.getVertex(2)){ sign = 1; rot = 0; return; @@ -279,5 +281,5 @@ void MTetrahedron::getFaceInfo (const MFace & face, int &ithFace, int &sign, int sign = -1; rot = 2; return; } } - throw; + Msg::Error("Could not get face information for tetrahedron %d", getNum()); } diff --git a/Geo/MTetrahedron.h b/Geo/MTetrahedron.h index bc98392d9a..0866496540 100644 --- a/Geo/MTetrahedron.h +++ b/Geo/MTetrahedron.h @@ -57,7 +57,7 @@ class MTetrahedron : public MElement { for(int i = 0; i < 4; i++) _v[i] = v[i]; } ~MTetrahedron(){} - virtual int getDim(){ return 3; } + virtual int getDim() const { return 3; } virtual int getNumVertices() const { return 4; } virtual MVertex *getVertex(int num){ return _v[num]; } virtual MVertex *getVertexMED(int num) @@ -89,7 +89,7 @@ class MTetrahedron : public MElement { _v[faces_tetra(num, 1)], _v[faces_tetra(num, 2)]); } - virtual void getFaceInfo (const MFace & face, int &ithFace, int &sign, int &rot)const; + virtual void getFaceInfo(const MFace & face, int &ithFace, int &sign, int &rot) const; virtual int getNumFacesRep(){ return 4; } virtual void getFaceRep(int num, double *x, double *y, double *z, SVector3 *n) { diff --git a/Geo/MTriangle.h b/Geo/MTriangle.h index b8ec8fef1d..27ed4d5491 100644 --- a/Geo/MTriangle.h +++ b/Geo/MTriangle.h @@ -49,7 +49,7 @@ class MTriangle : public MElement { for(int i = 0; i < 3; i++) _v[i] = v[i]; } ~MTriangle(){} - virtual int getDim(){ return 2; } + virtual int getDim() const { return 2; } virtual double gammaShapeMeasure(); virtual double distoShapeMeasure(); virtual double angleShapeMeasure(); @@ -72,8 +72,9 @@ class MTriangle : public MElement { { return MEdge(_v[edges_tri(num, 0)], _v[edges_tri(num, 1)]); } - virtual void getEdgeInfo (const MEdge & edge, int &ithEdge, int &sign) const { - for (ithEdge=0;ithEdge<3;ithEdge++){ + virtual void getEdgeInfo (const MEdge & edge, int &ithEdge, int &sign) const + { + for (ithEdge = 0; ithEdge < 3; ithEdge++){ const MVertex *v0 = _v[edges_tri(ithEdge, 0)]; const MVertex *v1 = _v[edges_tri(ithEdge, 1)]; if (v0 == edge.getVertex(0) && v1 == edge.getVertex(1)){ @@ -83,7 +84,7 @@ class MTriangle : public MElement { sign = -1; return; } } - throw; + Msg::Error("Could not get edge information for triangle %d", getNum()); } virtual int getNumEdgesRep(){ return 3; } virtual void getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n) -- GitLab