From 3c0792d5d90db2be298459f21b15de3eefb33157 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Sun, 17 May 2015 17:28:00 +0300 Subject: [PATCH] salomesmesh: suppress several warnings Warning was like: src/3rdParty/salomesmesh/src/SMESHDS/SMESHDS_Mesh.cpp|1028 col 5| warning: add explicit braces to avoid dangling else [-Wdangling-else] src/3rdParty/salomesmesh/src/SMESH/SMESH_MeshEditor.cpp|7377 col 27| warning: '&&' within '||' [-Wlogical-op-parentheses] --- .../src/Controls/SMESH_Controls.cpp | 8 ++--- .../src/SMESH/SMESH_MeshEditor.cpp | 29 ++++++++++++------- .../salomesmesh/src/SMESH/SMESH_subMesh.cpp | 3 +- .../src/SMESHDS/SMESHDS_GroupOnGeom.cpp | 3 +- .../salomesmesh/src/SMESHDS/SMESHDS_Mesh.cpp | 3 +- .../src/StdMeshers/StdMeshers_Hexa_3D.cpp | 8 +++++ .../StdMeshers/StdMeshers_ProjectionUtils.cpp | 2 +- 7 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/3rdParty/salomesmesh/src/Controls/SMESH_Controls.cpp b/src/3rdParty/salomesmesh/src/Controls/SMESH_Controls.cpp index 43387020e7..5bba654474 100644 --- a/src/3rdParty/salomesmesh/src/Controls/SMESH_Controls.cpp +++ b/src/3rdParty/salomesmesh/src/Controls/SMESH_Controls.cpp @@ -2162,8 +2162,8 @@ bool RangeOfIds::SetRangeStr( const TCollection_AsciiString& theStr ) while ( aMinStr.Search( "-" ) != -1 ) aMinStr.RemoveAll( '-' ); while ( aMaxStr.Search( "-" ) != -1 ) aMaxStr.RemoveAll( '-' ); - if ( !aMinStr.IsEmpty() && !aMinStr.IsIntegerValue() || - !aMaxStr.IsEmpty() && !aMaxStr.IsIntegerValue() ) + if ( (!aMinStr.IsEmpty() && !aMinStr.IsIntegerValue()) || + (!aMaxStr.IsEmpty() && !aMaxStr.IsIntegerValue()) ) return false; myMin.Append( aMinStr.IsEmpty() ? IntegerFirst() : aMinStr.IntegerValue() ); @@ -2209,7 +2209,7 @@ bool RangeOfIds::IsSatisfy( long theId ) else { const SMDS_MeshElement* anElem = myMesh->FindElement( theId ); - if ( anElem == 0 || myType != anElem->GetType() && myType != SMDSAbs_All ) + if ( anElem == 0 || (myType != anElem->GetType() && myType != SMDSAbs_All) ) return false; } @@ -2402,7 +2402,7 @@ bool LogicalOR::IsSatisfy( long theId ) (myPredicate2!=NULL) && ( myPredicate1->IsSatisfy( theId ) || myPredicate2->IsSatisfy( theId ) - ); + ); } diff --git a/src/3rdParty/salomesmesh/src/SMESH/SMESH_MeshEditor.cpp b/src/3rdParty/salomesmesh/src/SMESH/SMESH_MeshEditor.cpp index ad5fd5a271..0fb17abde1 100644 --- a/src/3rdParty/salomesmesh/src/SMESH/SMESH_MeshEditor.cpp +++ b/src/3rdParty/salomesmesh/src/SMESH/SMESH_MeshEditor.cpp @@ -130,9 +130,10 @@ SMESH_MeshEditor::AddElement(const vector & node, if ( nbnode == 2 ) if ( ID ) e = mesh->AddEdgeWithID(node[0], node[1], ID); else e = mesh->AddEdge (node[0], node[1] ); - else if ( nbnode == 3 ) + else if ( nbnode == 3 ) { if ( ID ) e = mesh->AddEdgeWithID(node[0], node[1], node[2], ID); else e = mesh->AddEdge (node[0], node[1], node[2] ); + } break; case SMDSAbs_Face: if ( !isPoly ) { @@ -147,11 +148,12 @@ SMESH_MeshEditor::AddElement(const vector & node, node[4], node[5], ID); else e = mesh->AddFace (node[0], node[1], node[2], node[3], node[4], node[5] ); - else if (nbnode == 8) + else if (nbnode == 8) { if ( ID ) e = mesh->AddFaceWithID(node[0], node[1], node[2], node[3], node[4], node[5], node[6], node[7], ID); else e = mesh->AddFace (node[0], node[1], node[2], node[3], node[4], node[5], node[6], node[7] ); + } } else { if ( ID ) e = mesh->AddPolygonalFaceWithID(node, ID); else e = mesh->AddPolygonalFace (node ); @@ -202,7 +204,7 @@ SMESH_MeshEditor::AddElement(const vector & node, node[4], node[5], node[6], node[7], node[8], node[9], node[10],node[11], node[12],node[13],node[14] ); - else if (nbnode == 20) + else if (nbnode == 20) { if ( ID ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3], node[4], node[5], node[6], node[7], node[8], node[9], node[10],node[11], @@ -213,6 +215,7 @@ SMESH_MeshEditor::AddElement(const vector & node, node[8], node[9], node[10],node[11], node[12],node[13],node[14],node[15], node[16],node[17],node[18],node[19] ); + } } } return e; @@ -514,12 +517,13 @@ bool SMESH_MeshEditor::InverseDiag (const SMDS_MeshElement * theTria1, // find indices of 1,2 and of A,B in theTria1 int iA = 0, iB = 0, i1 = 0, i2 = 0; for ( i = 0; i < 6; i++ ) { - if ( sameInd [ i ] == 0 ) + if ( sameInd [ i ] == 0 ) { if ( i < 3 ) i1 = i; else i2 = i; - else if (i < 3) + } else if (i < 3) { if ( iA ) iB = i; else iA = i; + } } // nodes 1 and 2 should not be the same if ( aNodes[ i1 ] == aNodes[ i2 ] ) @@ -612,7 +616,7 @@ static bool findTriangles(const SMDS_MeshNode * theNode1, it = theNode2->GetInverseElementIterator(SMDSAbs_Face); while (it->more()) { const SMDS_MeshElement* elem = it->next(); - if ( emap.find( elem ) != emap.end() ) + if ( emap.find( elem ) != emap.end() ) { if ( theTria1 ) { // theTria1 must be element with minimum ID if( theTria1->GetID() < elem->GetID() ) { @@ -627,6 +631,7 @@ static bool findTriangles(const SMDS_MeshNode * theNode1, else { theTria1 = elem; } + } } return ( theTria1 && theTria2 ); } @@ -1391,7 +1396,7 @@ double getAngle(const SMDS_MeshElement * tr1, int i = 0, iDiag = -1; while ( it->more()) { const SMDS_MeshElement *n = it->next(); - if ( n == n1 || n == n2 ) + if ( n == n1 || n == n2 ) { if ( iDiag < 0) iDiag = i; else { @@ -1401,6 +1406,7 @@ double getAngle(const SMDS_MeshElement * tr1, nFirst[ t ] = n; break; } + } i++; } } @@ -4362,11 +4368,12 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems, // Regular elements int* i = index[ FORWARD ]; - if ( needReverse && nbNodes > 2) // reverse mirrored faces and volumes + if ( needReverse && nbNodes > 2) { // reverse mirrored faces and volumes if ( elemType == SMDSAbs_Face ) i = index[ REV_FACE ]; else i = index[ nbNodes - 4 ]; + } if(elem->IsQuadratic()) { static int anIds[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; @@ -4440,8 +4447,8 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems, PGroupIDs newGroupIDs; - if ( theMakeGroups && theCopy || - theMakeGroups && theTargetMesh ) + if ( (theMakeGroups && theCopy) || + (theMakeGroups && theTargetMesh) ) newGroupIDs = generateGroups( srcNodes, srcElems, groupPostfix, theTargetMesh ); return newGroupIDs; @@ -7374,7 +7381,7 @@ SMESH_MeshEditor::Sew_Error } // check similarity of elements of the sides - if (aResult == SEW_OK && ( face[0] && !face[1] ) || ( !face[0] && face[1] )) { + if ((aResult == SEW_OK && ( face[0] && !face[1] )) || ( !face[0] && face[1] )) { MESSAGE("Correspondent face not found on side " << ( face[0] ? 1 : 0 )); if ( nReplaceMap.size() == 2 ) { // faces on input nodes not found aResult = ( face[0] ? SEW_BAD_SIDE2_NODES : SEW_BAD_SIDE1_NODES ); diff --git a/src/3rdParty/salomesmesh/src/SMESH/SMESH_subMesh.cpp b/src/3rdParty/salomesmesh/src/SMESH/SMESH_subMesh.cpp index 9ad3d28ef2..6de2eaf201 100644 --- a/src/3rdParty/salomesmesh/src/SMESH/SMESH_subMesh.cpp +++ b/src/3rdParty/salomesmesh/src/SMESH/SMESH_subMesh.cpp @@ -1508,11 +1508,12 @@ bool SMESH_subMesh::ComputeStateEngine(int event) ComputeSubMeshStateEngine( CHECK_COMPUTE_STATE ); break; case CHECK_COMPUTE_STATE: - if ( !IsMeshComputed() ) + if ( !IsMeshComputed() ) { if (_algoState == HYP_OK) _computeState = READY_TO_COMPUTE; else _computeState = NOT_READY; + } break; default: ASSERT(0); diff --git a/src/3rdParty/salomesmesh/src/SMESHDS/SMESHDS_GroupOnGeom.cpp b/src/3rdParty/salomesmesh/src/SMESHDS/SMESHDS_GroupOnGeom.cpp index a4ed012742..f528c6aacb 100644 --- a/src/3rdParty/salomesmesh/src/SMESHDS/SMESHDS_GroupOnGeom.cpp +++ b/src/3rdParty/salomesmesh/src/SMESHDS/SMESHDS_GroupOnGeom.cpp @@ -65,13 +65,14 @@ class MyIterator: public SMDS_ElemIterator MyIterator(SMDSAbs_ElementType type, const SMESHDS_SubMesh* subMesh) : myType(type), myElem(0) { - if ( subMesh ) + if ( subMesh ) { if ( myType == SMDSAbs_Node ) myNodeIt = subMesh->GetNodes(); else { myElemIt = subMesh->GetElements(); next(); } + } } bool more() { diff --git a/src/3rdParty/salomesmesh/src/SMESHDS/SMESHDS_Mesh.cpp b/src/3rdParty/salomesmesh/src/SMESHDS/SMESHDS_Mesh.cpp index 648ad83e52..18b0388af8 100644 --- a/src/3rdParty/salomesmesh/src/SMESHDS/SMESHDS_Mesh.cpp +++ b/src/3rdParty/salomesmesh/src/SMESHDS/SMESHDS_Mesh.cpp @@ -1022,11 +1022,12 @@ void SMESHDS_Mesh::UnSetMeshElementOnShape(const SMDS_MeshElement * elem, int Index = myIndexToShape.FindIndex(S); map::iterator it = myShapeIndexToSubMesh.find( Index ); - if ( it != myShapeIndexToSubMesh.end() ) + if ( it != myShapeIndexToSubMesh.end() ) { if ( elem->GetType() == SMDSAbs_Node ) it->second->RemoveNode( static_cast( elem ), /*deleted=*/false ); else it->second->RemoveElement( elem, /*deleted=*/false ); + } } //======================================================================= diff --git a/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_Hexa_3D.cpp b/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_Hexa_3D.cpp index 2a0c7de338..8eb1ae4b01 100644 --- a/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_Hexa_3D.cpp +++ b/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_Hexa_3D.cpp @@ -876,6 +876,7 @@ void StdMeshers_Hexa_3D::GetConv2DCoefs(const faceQuadStruct & quad, int a1, b1, c1, a2, b2, c2; if (VA.IsSame(V0)) + { if (VB.IsSame(V1)) { a1 = 1; @@ -895,7 +896,9 @@ void StdMeshers_Hexa_3D::GetConv2DCoefs(const faceQuadStruct & quad, b2 = 0; c2 = 0; // x } + } if (VA.IsSame(V1)) + { if (VB.IsSame(V2)) { a1 = 0; @@ -915,7 +918,9 @@ void StdMeshers_Hexa_3D::GetConv2DCoefs(const faceQuadStruct & quad, b2 = 1; c2 = 0; // y } + } if (VA.IsSame(V2)) + { if (VB.IsSame(V3)) { a1 = -1; @@ -935,7 +940,9 @@ void StdMeshers_Hexa_3D::GetConv2DCoefs(const faceQuadStruct & quad, b2 = 0; c2 = 1; // 1-x } + } if (VA.IsSame(V3)) + { if (VB.IsSame(V0)) { a1 = 0; @@ -955,6 +962,7 @@ void StdMeshers_Hexa_3D::GetConv2DCoefs(const faceQuadStruct & quad, b2 = -1; c2 = 1; // 1-y } + } // MESSAGE("X = " << c1 << "+ " << a1 << "*x + " << b1 << "*y"); // MESSAGE("Y = " << c2 << "+ " << a2 << "*x + " << b2 << "*y"); conv.a1 = a1; diff --git a/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_ProjectionUtils.cpp b/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_ProjectionUtils.cpp index 8e01fb74bf..c7ca13380f 100644 --- a/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_ProjectionUtils.cpp +++ b/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_ProjectionUtils.cpp @@ -1245,7 +1245,7 @@ bool StdMeshers_ProjectionUtils::IsSubShape( const TopoDS_Shape& shape, return aMesh->GetMeshDS()->ShapeToIndex( shape ) || // PAL16202 - shape.ShapeType() == TopAbs_COMPOUND && aMesh->GetMeshDS()->IsGroupOfSubShapes( shape ); + (shape.ShapeType() == TopAbs_COMPOUND && aMesh->GetMeshDS()->IsGroupOfSubShapes( shape )); } //=======================================================================