X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FControls%2FSMESH_Controls.cxx;h=e4efffe41c6dadb48bb69d664735b293289f60ee;hp=769096df4344b7e69a9d61ac59e8d7d6d903b5f9;hb=65c1beab50fcec33a4e988c10b3fedb081543164;hpb=193c49c87753b6ccabb2b5e6dc935aa480d2d43e diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index 769096df4..e4efffe41 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -174,7 +175,7 @@ namespace { n += q2 ^ q3; } double len = n.Modulus(); - bool zeroLen = ( len <= numeric_limits::min()); + bool zeroLen = ( len <= std::numeric_limits::min()); if ( !zeroLen ) n /= len; @@ -311,12 +312,12 @@ double NumericalFunctor::Round( const double & aVal ) */ //================================================================================ -void NumericalFunctor::GetHistogram(int nbIntervals, - std::vector& nbEvents, - std::vector& funValues, - const vector& elements, - const double* minmax, - const bool isLogarithmic) +void NumericalFunctor::GetHistogram(int nbIntervals, + std::vector& nbEvents, + std::vector& funValues, + const std::vector& elements, + const double* minmax, + const bool isLogarithmic) { if ( nbIntervals < 1 || !myMesh || @@ -335,7 +336,7 @@ void NumericalFunctor::GetHistogram(int nbIntervals, } else { - vector::const_iterator id = elements.begin(); + std::vector::const_iterator id = elements.begin(); for ( ; id != elements.end(); ++id ) values.insert( GetValue( *id )); } @@ -521,148 +522,164 @@ double MaxElementLength3D::GetValue( long theElementId ) if( GetPoints( theElementId, P ) ) { double aVal = 0; const SMDS_MeshElement* aElem = myMesh->FindElement( theElementId ); - SMDSAbs_ElementType aType = aElem->GetType(); + SMDSAbs_EntityType aType = aElem->GetEntityType(); int len = P.size(); - switch( aType ) { - case SMDSAbs_Volume: - if( len == 4 ) { // tetras - double L1 = getDistance(P( 1 ),P( 2 )); - double L2 = getDistance(P( 2 ),P( 3 )); - double L3 = getDistance(P( 3 ),P( 1 )); - double L4 = getDistance(P( 1 ),P( 4 )); - double L5 = getDistance(P( 2 ),P( 4 )); - double L6 = getDistance(P( 3 ),P( 4 )); - aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); - break; - } - else if( len == 5 ) { // pyramids - double L1 = getDistance(P( 1 ),P( 2 )); - double L2 = getDistance(P( 2 ),P( 3 )); - double L3 = getDistance(P( 3 ),P( 4 )); - double L4 = getDistance(P( 4 ),P( 1 )); - double L5 = getDistance(P( 1 ),P( 5 )); - double L6 = getDistance(P( 2 ),P( 5 )); - double L7 = getDistance(P( 3 ),P( 5 )); - double L8 = getDistance(P( 4 ),P( 5 )); - aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); - aVal = Max(aVal,Max(L7,L8)); - break; - } - else if( len == 6 ) { // pentas - double L1 = getDistance(P( 1 ),P( 2 )); - double L2 = getDistance(P( 2 ),P( 3 )); - double L3 = getDistance(P( 3 ),P( 1 )); - double L4 = getDistance(P( 4 ),P( 5 )); - double L5 = getDistance(P( 5 ),P( 6 )); - double L6 = getDistance(P( 6 ),P( 4 )); - double L7 = getDistance(P( 1 ),P( 4 )); - double L8 = getDistance(P( 2 ),P( 5 )); - double L9 = getDistance(P( 3 ),P( 6 )); - aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); - aVal = Max(aVal,Max(Max(L7,L8),L9)); - break; - } - else if( len == 8 ) { // hexas - double L1 = getDistance(P( 1 ),P( 2 )); - double L2 = getDistance(P( 2 ),P( 3 )); - double L3 = getDistance(P( 3 ),P( 4 )); - double L4 = getDistance(P( 4 ),P( 1 )); - double L5 = getDistance(P( 5 ),P( 6 )); - double L6 = getDistance(P( 6 ),P( 7 )); - double L7 = getDistance(P( 7 ),P( 8 )); - double L8 = getDistance(P( 8 ),P( 5 )); - double L9 = getDistance(P( 1 ),P( 5 )); - double L10= getDistance(P( 2 ),P( 6 )); - double L11= getDistance(P( 3 ),P( 7 )); - double L12= getDistance(P( 4 ),P( 8 )); - double D1 = getDistance(P( 1 ),P( 7 )); - double D2 = getDistance(P( 2 ),P( 8 )); - double D3 = getDistance(P( 3 ),P( 5 )); - double D4 = getDistance(P( 4 ),P( 6 )); - aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); - aVal = Max(aVal,Max(Max(L7,L8),Max(L9,L10))); - aVal = Max(aVal,Max(L11,L12)); - aVal = Max(aVal,Max(Max(D1,D2),Max(D3,D4))); - break; - } - else if( len == 12 ) { // hexagonal prism - for ( int i1 = 1; i1 < 12; ++i1 ) - for ( int i2 = i1+1; i1 <= 12; ++i1 ) - aVal = Max( aVal, getDistance(P( i1 ),P( i2 ))); - break; - } - else if( len == 10 ) { // quadratic tetras - double L1 = getDistance(P( 1 ),P( 5 )) + getDistance(P( 5 ),P( 2 )); - double L2 = getDistance(P( 2 ),P( 6 )) + getDistance(P( 6 ),P( 3 )); - double L3 = getDistance(P( 3 ),P( 7 )) + getDistance(P( 7 ),P( 1 )); - double L4 = getDistance(P( 1 ),P( 8 )) + getDistance(P( 8 ),P( 4 )); - double L5 = getDistance(P( 2 ),P( 9 )) + getDistance(P( 9 ),P( 4 )); - double L6 = getDistance(P( 3 ),P( 10 )) + getDistance(P( 10 ),P( 4 )); - aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); - break; - } - else if( len == 13 ) { // quadratic pyramids - double L1 = getDistance(P( 1 ),P( 6 )) + getDistance(P( 6 ),P( 2 )); - double L2 = getDistance(P( 2 ),P( 7 )) + getDistance(P( 7 ),P( 3 )); - double L3 = getDistance(P( 3 ),P( 8 )) + getDistance(P( 8 ),P( 4 )); - double L4 = getDistance(P( 4 ),P( 9 )) + getDistance(P( 9 ),P( 1 )); - double L5 = getDistance(P( 1 ),P( 10 )) + getDistance(P( 10 ),P( 5 )); - double L6 = getDistance(P( 2 ),P( 11 )) + getDistance(P( 11 ),P( 5 )); - double L7 = getDistance(P( 3 ),P( 12 )) + getDistance(P( 12 ),P( 5 )); - double L8 = getDistance(P( 4 ),P( 13 )) + getDistance(P( 13 ),P( 5 )); - aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); - aVal = Max(aVal,Max(L7,L8)); - break; - } - else if( len == 15 ) { // quadratic pentas - double L1 = getDistance(P( 1 ),P( 7 )) + getDistance(P( 7 ),P( 2 )); - double L2 = getDistance(P( 2 ),P( 8 )) + getDistance(P( 8 ),P( 3 )); - double L3 = getDistance(P( 3 ),P( 9 )) + getDistance(P( 9 ),P( 1 )); - double L4 = getDistance(P( 4 ),P( 10 )) + getDistance(P( 10 ),P( 5 )); - double L5 = getDistance(P( 5 ),P( 11 )) + getDistance(P( 11 ),P( 6 )); - double L6 = getDistance(P( 6 ),P( 12 )) + getDistance(P( 12 ),P( 4 )); - double L7 = getDistance(P( 1 ),P( 13 )) + getDistance(P( 13 ),P( 4 )); - double L8 = getDistance(P( 2 ),P( 14 )) + getDistance(P( 14 ),P( 5 )); - double L9 = getDistance(P( 3 ),P( 15 )) + getDistance(P( 15 ),P( 6 )); - aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); - aVal = Max(aVal,Max(Max(L7,L8),L9)); - break; - } - else if( len == 20 || len == 27 ) { // quadratic hexas - double L1 = getDistance(P( 1 ),P( 9 )) + getDistance(P( 9 ),P( 2 )); - double L2 = getDistance(P( 2 ),P( 10 )) + getDistance(P( 10 ),P( 3 )); - double L3 = getDistance(P( 3 ),P( 11 )) + getDistance(P( 11 ),P( 4 )); - double L4 = getDistance(P( 4 ),P( 12 )) + getDistance(P( 12 ),P( 1 )); - double L5 = getDistance(P( 5 ),P( 13 )) + getDistance(P( 13 ),P( 6 )); - double L6 = getDistance(P( 6 ),P( 14 )) + getDistance(P( 14 ),P( 7 )); - double L7 = getDistance(P( 7 ),P( 15 )) + getDistance(P( 15 ),P( 8 )); - double L8 = getDistance(P( 8 ),P( 16 )) + getDistance(P( 16 ),P( 5 )); - double L9 = getDistance(P( 1 ),P( 17 )) + getDistance(P( 17 ),P( 5 )); - double L10= getDistance(P( 2 ),P( 18 )) + getDistance(P( 18 ),P( 6 )); - double L11= getDistance(P( 3 ),P( 19 )) + getDistance(P( 19 ),P( 7 )); - double L12= getDistance(P( 4 ),P( 20 )) + getDistance(P( 20 ),P( 8 )); - double D1 = getDistance(P( 1 ),P( 7 )); - double D2 = getDistance(P( 2 ),P( 8 )); - double D3 = getDistance(P( 3 ),P( 5 )); - double D4 = getDistance(P( 4 ),P( 6 )); - aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); - aVal = Max(aVal,Max(Max(L7,L8),Max(L9,L10))); - aVal = Max(aVal,Max(L11,L12)); - aVal = Max(aVal,Max(Max(D1,D2),Max(D3,D4))); - break; - } - else if( len > 1 && aElem->IsPoly() ) { // polys - // get the maximum distance between all pairs of nodes - for( int i = 1; i <= len; i++ ) { - for( int j = 1; j <= len; j++ ) { - if( j > i ) { // optimization of the loop - double D = getDistance( P(i), P(j) ); - aVal = Max( aVal, D ); - } + switch ( aType ) { + case SMDSEntity_Tetra: { // tetras + double L1 = getDistance(P( 1 ),P( 2 )); + double L2 = getDistance(P( 2 ),P( 3 )); + double L3 = getDistance(P( 3 ),P( 1 )); + double L4 = getDistance(P( 1 ),P( 4 )); + double L5 = getDistance(P( 2 ),P( 4 )); + double L6 = getDistance(P( 3 ),P( 4 )); + aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); + break; + } + case SMDSEntity_Pyramid: { // pyramids + double L1 = getDistance(P( 1 ),P( 2 )); + double L2 = getDistance(P( 2 ),P( 3 )); + double L3 = getDistance(P( 3 ),P( 4 )); + double L4 = getDistance(P( 4 ),P( 1 )); + double L5 = getDistance(P( 1 ),P( 5 )); + double L6 = getDistance(P( 2 ),P( 5 )); + double L7 = getDistance(P( 3 ),P( 5 )); + double L8 = getDistance(P( 4 ),P( 5 )); + aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); + aVal = Max(aVal,Max(L7,L8)); + break; + } + case SMDSEntity_Penta: { // pentas + double L1 = getDistance(P( 1 ),P( 2 )); + double L2 = getDistance(P( 2 ),P( 3 )); + double L3 = getDistance(P( 3 ),P( 1 )); + double L4 = getDistance(P( 4 ),P( 5 )); + double L5 = getDistance(P( 5 ),P( 6 )); + double L6 = getDistance(P( 6 ),P( 4 )); + double L7 = getDistance(P( 1 ),P( 4 )); + double L8 = getDistance(P( 2 ),P( 5 )); + double L9 = getDistance(P( 3 ),P( 6 )); + aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); + aVal = Max(aVal,Max(Max(L7,L8),L9)); + break; + } + case SMDSEntity_Hexa: { // hexas + double L1 = getDistance(P( 1 ),P( 2 )); + double L2 = getDistance(P( 2 ),P( 3 )); + double L3 = getDistance(P( 3 ),P( 4 )); + double L4 = getDistance(P( 4 ),P( 1 )); + double L5 = getDistance(P( 5 ),P( 6 )); + double L6 = getDistance(P( 6 ),P( 7 )); + double L7 = getDistance(P( 7 ),P( 8 )); + double L8 = getDistance(P( 8 ),P( 5 )); + double L9 = getDistance(P( 1 ),P( 5 )); + double L10= getDistance(P( 2 ),P( 6 )); + double L11= getDistance(P( 3 ),P( 7 )); + double L12= getDistance(P( 4 ),P( 8 )); + double D1 = getDistance(P( 1 ),P( 7 )); + double D2 = getDistance(P( 2 ),P( 8 )); + double D3 = getDistance(P( 3 ),P( 5 )); + double D4 = getDistance(P( 4 ),P( 6 )); + aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); + aVal = Max(aVal,Max(Max(L7,L8),Max(L9,L10))); + aVal = Max(aVal,Max(L11,L12)); + aVal = Max(aVal,Max(Max(D1,D2),Max(D3,D4))); + break; + } + case SMDSEntity_Hexagonal_Prism: { // hexagonal prism + for ( int i1 = 1; i1 < 12; ++i1 ) + for ( int i2 = i1+1; i1 <= 12; ++i1 ) + aVal = Max( aVal, getDistance(P( i1 ),P( i2 ))); + break; + } + case SMDSEntity_Quad_Tetra: { // quadratic tetras + double L1 = getDistance(P( 1 ),P( 5 )) + getDistance(P( 5 ),P( 2 )); + double L2 = getDistance(P( 2 ),P( 6 )) + getDistance(P( 6 ),P( 3 )); + double L3 = getDistance(P( 3 ),P( 7 )) + getDistance(P( 7 ),P( 1 )); + double L4 = getDistance(P( 1 ),P( 8 )) + getDistance(P( 8 ),P( 4 )); + double L5 = getDistance(P( 2 ),P( 9 )) + getDistance(P( 9 ),P( 4 )); + double L6 = getDistance(P( 3 ),P( 10 )) + getDistance(P( 10 ),P( 4 )); + aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); + break; + } + case SMDSEntity_Quad_Pyramid: { // quadratic pyramids + double L1 = getDistance(P( 1 ),P( 6 )) + getDistance(P( 6 ),P( 2 )); + double L2 = getDistance(P( 2 ),P( 7 )) + getDistance(P( 7 ),P( 3 )); + double L3 = getDistance(P( 3 ),P( 8 )) + getDistance(P( 8 ),P( 4 )); + double L4 = getDistance(P( 4 ),P( 9 )) + getDistance(P( 9 ),P( 1 )); + double L5 = getDistance(P( 1 ),P( 10 )) + getDistance(P( 10 ),P( 5 )); + double L6 = getDistance(P( 2 ),P( 11 )) + getDistance(P( 11 ),P( 5 )); + double L7 = getDistance(P( 3 ),P( 12 )) + getDistance(P( 12 ),P( 5 )); + double L8 = getDistance(P( 4 ),P( 13 )) + getDistance(P( 13 ),P( 5 )); + aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); + aVal = Max(aVal,Max(L7,L8)); + break; + } + case SMDSEntity_Quad_Penta: { // quadratic pentas + double L1 = getDistance(P( 1 ),P( 7 )) + getDistance(P( 7 ),P( 2 )); + double L2 = getDistance(P( 2 ),P( 8 )) + getDistance(P( 8 ),P( 3 )); + double L3 = getDistance(P( 3 ),P( 9 )) + getDistance(P( 9 ),P( 1 )); + double L4 = getDistance(P( 4 ),P( 10 )) + getDistance(P( 10 ),P( 5 )); + double L5 = getDistance(P( 5 ),P( 11 )) + getDistance(P( 11 ),P( 6 )); + double L6 = getDistance(P( 6 ),P( 12 )) + getDistance(P( 12 ),P( 4 )); + double L7 = getDistance(P( 1 ),P( 13 )) + getDistance(P( 13 ),P( 4 )); + double L8 = getDistance(P( 2 ),P( 14 )) + getDistance(P( 14 ),P( 5 )); + double L9 = getDistance(P( 3 ),P( 15 )) + getDistance(P( 15 ),P( 6 )); + aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); + aVal = Max(aVal,Max(Max(L7,L8),L9)); + break; + } + case SMDSEntity_Quad_Hexa: + case SMDSEntity_TriQuad_Hexa: { // quadratic hexas + double L1 = getDistance(P( 1 ),P( 9 )) + getDistance(P( 9 ),P( 2 )); + double L2 = getDistance(P( 2 ),P( 10 )) + getDistance(P( 10 ),P( 3 )); + double L3 = getDistance(P( 3 ),P( 11 )) + getDistance(P( 11 ),P( 4 )); + double L4 = getDistance(P( 4 ),P( 12 )) + getDistance(P( 12 ),P( 1 )); + double L5 = getDistance(P( 5 ),P( 13 )) + getDistance(P( 13 ),P( 6 )); + double L6 = getDistance(P( 6 ),P( 14 )) + getDistance(P( 14 ),P( 7 )); + double L7 = getDistance(P( 7 ),P( 15 )) + getDistance(P( 15 ),P( 8 )); + double L8 = getDistance(P( 8 ),P( 16 )) + getDistance(P( 16 ),P( 5 )); + double L9 = getDistance(P( 1 ),P( 17 )) + getDistance(P( 17 ),P( 5 )); + double L10= getDistance(P( 2 ),P( 18 )) + getDistance(P( 18 ),P( 6 )); + double L11= getDistance(P( 3 ),P( 19 )) + getDistance(P( 19 ),P( 7 )); + double L12= getDistance(P( 4 ),P( 20 )) + getDistance(P( 20 ),P( 8 )); + double D1 = getDistance(P( 1 ),P( 7 )); + double D2 = getDistance(P( 2 ),P( 8 )); + double D3 = getDistance(P( 3 ),P( 5 )); + double D4 = getDistance(P( 4 ),P( 6 )); + aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6)); + aVal = Max(aVal,Max(Max(L7,L8),Max(L9,L10))); + aVal = Max(aVal,Max(L11,L12)); + aVal = Max(aVal,Max(Max(D1,D2),Max(D3,D4))); + break; + } + case SMDSEntity_Quad_Polyhedra: + case SMDSEntity_Polyhedra: { // polys + // get the maximum distance between all pairs of nodes + for( int i = 1; i <= len; i++ ) { + for( int j = 1; j <= len; j++ ) { + if( j > i ) { // optimization of the loop + double D = getDistance( P(i), P(j) ); + aVal = Max( aVal, D ); } } } + break; } + case SMDSEntity_Node: + case SMDSEntity_0D: + case SMDSEntity_Edge: + case SMDSEntity_Quad_Edge: + case SMDSEntity_Triangle: + case SMDSEntity_Quad_Triangle: + case SMDSEntity_BiQuad_Triangle: + case SMDSEntity_Quadrangle: + case SMDSEntity_Quad_Quadrangle: + case SMDSEntity_BiQuad_Quadrangle: + case SMDSEntity_Polygon: + case SMDSEntity_Quad_Polygon: + case SMDSEntity_Ball: + case SMDSEntity_Last: return 0; + } // switch ( aType ) if( myPrecision >= 0 ) { @@ -701,7 +718,7 @@ double MinimumAngle::GetValue( const TSequenceOfXYZ& P ) aMin = getAngle(P( P.size() ), P( 1 ), P( 2 )); aMin = Min(aMin,getAngle(P( P.size()-1 ), P( P.size() ), P( 1 ))); - for ( int i = 2; i < P.size(); i++ ) + for ( size_t i = 2; i < P.size(); i++ ) { double A0 = getAngle( P( i-1 ), P( i ), P( i+1 ) ); aMin = Min(aMin,A0); @@ -1476,10 +1493,10 @@ double Area::GetValue( const TSequenceOfXYZ& P ) gp_Vec aVec2( P(3) - P(1) ); gp_Vec SumVec = aVec1 ^ aVec2; - for (int i=4; i<=P.size(); i++) + for (size_t i=4; i<=P.size(); i++) { gp_Vec aVec1( P(i-1) - P(1) ); - gp_Vec aVec2( P(i) - P(1) ); + gp_Vec aVec2( P(i ) - P(1) ); gp_Vec tmp = aVec1 ^ aVec2; SumVec.Add(tmp); } @@ -1815,10 +1832,10 @@ void Length2D::GetValues(TValues& theValues) dynamic_cast(anElem); // use special nodes iterator SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator(); - long aNodeId[4]; + long aNodeId[4] = { 0,0,0,0 }; gp_Pnt P[4]; - double aLength; + double aLength = 0; const SMDS_MeshElement* aNode; if(anIter->more()){ aNode = anIter->next(); @@ -1940,7 +1957,7 @@ double MultiConnection2D::GetValue( long theElementId ) SMDS_ElemIteratorPtr anIter = aFaceElem->nodesIterator(); if (!anIter) break; - const SMDS_MeshNode *aNode, *aNode0; + const SMDS_MeshNode *aNode, *aNode0 = 0; TColStd_MapOfInteger aMap, aMapPrev; for (i = 0; i <= len; i++) { @@ -2021,7 +2038,7 @@ void MultiConnection2D::GetValues(MValues& theValues) (anElem)->interlacedNodesElemIterator(); else aNodesIter = anElem->nodesIterator(); - long aNodeId[3]; + long aNodeId[3] = {0,0,0}; //int aNbConnects=0; const SMDS_MeshNode* aNode0; @@ -2146,7 +2163,7 @@ bool BareBorderVolume::IsSatisfy(long theElementId ) if ( myTool.IsFreeFace( iF )) { const SMDS_MeshNode** n = myTool.GetFaceNodes(iF); - vector< const SMDS_MeshNode*> nodes( n, n+myTool.NbFaceNodes(iF)); + std::vector< const SMDS_MeshNode*> nodes( n, n+myTool.NbFaceNodes(iF)); if ( !myMesh->FindElement( nodes, SMDSAbs_Face, /*Nomedium=*/false)) return true; } @@ -2285,15 +2302,15 @@ void CoincidentNodes::SetMesh( const SMDS_Mesh* theMesh ) while ( nIt->more() ) nodesToCheck.insert( nodesToCheck.end(), nIt->next() ); - list< list< const SMDS_MeshNode*> > nodeGroups; + std::list< std::list< const SMDS_MeshNode*> > nodeGroups; SMESH_OctreeNode::FindCoincidentNodes ( nodesToCheck, &nodeGroups, myToler ); myCoincidentIDs.Clear(); - list< list< const SMDS_MeshNode*> >::iterator groupIt = nodeGroups.begin(); + std::list< std::list< const SMDS_MeshNode*> >::iterator groupIt = nodeGroups.begin(); for ( ; groupIt != nodeGroups.end(); ++groupIt ) { - list< const SMDS_MeshNode*>& coincNodes = *groupIt; - list< const SMDS_MeshNode*>::iterator n = coincNodes.begin(); + std::list< const SMDS_MeshNode*>& coincNodes = *groupIt; + std::list< const SMDS_MeshNode*>::iterator n = coincNodes.begin(); for ( ; n != coincNodes.end(); ++n ) myCoincidentIDs.Add( (*n)->GetID() ); } @@ -2325,7 +2342,7 @@ bool CoincidentElements::IsSatisfy( long theElementId ) if ( const SMDS_MeshElement* e = myMesh->FindElement( theElementId )) { if ( e->GetType() != GetType() ) return false; - set< const SMDS_MeshNode* > elemNodes( e->begin_nodes(), e->end_nodes() ); + std::set< const SMDS_MeshNode* > elemNodes( e->begin_nodes(), e->end_nodes() ); const int nbNodes = e->NbNodes(); SMDS_ElemIteratorPtr invIt = (*elemNodes.begin())->GetInverseElementIterator( GetType() ); while ( invIt->more() ) @@ -2494,7 +2511,7 @@ void FreeEdges::GetBoreders(TBorders& theBorders) interlacedNodesElemIterator(); else aNodesIter = anElem->nodesIterator(); - long aNodeId[2]; + long aNodeId[2] = {0,0}; const SMDS_MeshElement* aNode; if(aNodesIter->more()){ aNode = aNodesIter->next(); @@ -2572,18 +2589,20 @@ bool FreeFaces::IsSatisfy( long theId ) int nbNode = aFace->NbNodes(); // collect volumes to check that number of volumes with count equal nbNode not less than 2 - typedef map< SMDS_MeshElement*, int > TMapOfVolume; // map of volume counters - typedef map< SMDS_MeshElement*, int >::iterator TItrMapOfVolume; // iterator + typedef std::map< SMDS_MeshElement*, int > TMapOfVolume; // map of volume counters + typedef std::map< SMDS_MeshElement*, int >::iterator TItrMapOfVolume; // iterator TMapOfVolume mapOfVol; SMDS_ElemIteratorPtr nodeItr = aFace->nodesIterator(); - while ( nodeItr->more() ) { + while ( nodeItr->more() ) + { const SMDS_MeshNode* aNode = static_cast(nodeItr->next()); if ( !aNode ) continue; SMDS_ElemIteratorPtr volItr = aNode->GetInverseElementIterator(SMDSAbs_Volume); - while ( volItr->more() ) { + while ( volItr->more() ) + { SMDS_MeshElement* aVol = (SMDS_MeshElement*)volItr->next(); - TItrMapOfVolume itr = mapOfVol.insert(make_pair(aVol, 0)).first; + TItrMapOfVolume itr = mapOfVol.insert( std::make_pair( aVol, 0 )).first; (*itr).second++; } } @@ -2687,8 +2706,8 @@ void GroupColor::SetMesh( const SMDS_Mesh* theMesh ) return; // iterates on groups and find necessary elements ids - const std::set& aGroups = aMesh->GetGroups(); - set::const_iterator GrIt = aGroups.begin(); + const std::set& aGroups = aMesh->GetGroups(); + std::set::const_iterator GrIt = aGroups.begin(); for (; GrIt != aGroups.end(); GrIt++) { SMESHDS_GroupBase* aGrp = (*GrIt); @@ -2915,10 +2934,10 @@ void ConnectedElements::SetPoint( double x, double y, double z ) // find myNodeID by myXYZ if possible if ( myMeshModifTracer.GetMesh() ) { - auto_ptr searcher + SMESHUtils::Deleter searcher ( SMESH_MeshAlgos::GetElementSearcher( (SMDS_Mesh&) *myMeshModifTracer.GetMesh() )); - vector< const SMDS_MeshElement* > foundElems; + std::vector< const SMDS_MeshElement* > foundElems; searcher->FindElementsByPoint( gp_Pnt(x,y,z), SMDSAbs_All, foundElems ); if ( !foundElems.empty() ) @@ -2944,7 +2963,7 @@ bool ConnectedElements::IsSatisfy( long theElementId ) if ( !node0 ) return false; - list< const SMDS_MeshNode* > nodeQueue( 1, node0 ); + std::list< const SMDS_MeshNode* > nodeQueue( 1, node0 ); std::set< int > checkedNodeIDs; // algo: // foreach node in nodeQueue: @@ -2994,6 +3013,17 @@ bool ConnectedElements::IsSatisfy( long theElementId ) */ //================================================================================ +namespace +{ + inline bool isLessAngle( const gp_Vec& v1, const gp_Vec& v2, const double cos ) + { + double dot = v1 * v2; // cos * |v1| * |v2| + double l1 = v1.SquareMagnitude(); + double l2 = v2.SquareMagnitude(); + return (( dot * cos >= 0 ) && + ( dot * dot ) / l1 / l2 >= ( cos * cos )); + } +} CoplanarFaces::CoplanarFaces() : myFaceID(0), myToler(0) { @@ -3005,7 +3035,7 @@ void CoplanarFaces::SetMesh( const SMDS_Mesh* theMesh ) { // Build a set of coplanar face ids - myCoplanarIDs.clear(); + myCoplanarIDs.Clear(); if ( !myMeshModifTracer.GetMesh() || !myFaceID || !myToler ) return; @@ -3019,11 +3049,11 @@ void CoplanarFaces::SetMesh( const SMDS_Mesh* theMesh ) if (!normOK) return; - const double radianTol = myToler * M_PI / 180.; - std::set< SMESH_TLink > checkedLinks; + const double cosTol = Cos( myToler * M_PI / 180. ); + NCollection_Map< SMESH_TLink, SMESH_TLink > checkedLinks; - std::list< pair< const SMDS_MeshElement*, gp_Vec > > faceQueue; - faceQueue.push_back( make_pair( face, myNorm )); + std::list< std::pair< const SMDS_MeshElement*, gp_Vec > > faceQueue; + faceQueue.push_back( std::make_pair( face, myNorm )); while ( !faceQueue.empty() ) { face = faceQueue.front().first; @@ -3034,7 +3064,7 @@ void CoplanarFaces::SetMesh( const SMDS_Mesh* theMesh ) { const SMDS_MeshNode* n1 = face->GetNode( i ); const SMDS_MeshNode* n2 = face->GetNode(( i+1 )%nbN); - if ( !checkedLinks.insert( SMESH_TLink( n1, n2 )).second ) + if ( !checkedLinks.Add( SMESH_TLink( n1, n2 ))) continue; SMDS_ElemIteratorPtr fIt = n1->GetInverseElementIterator(SMDSAbs_Face); while ( fIt->more() ) @@ -3043,10 +3073,10 @@ void CoplanarFaces::SetMesh( const SMDS_Mesh* theMesh ) if ( f->GetNodeIndex( n2 ) > -1 ) { gp_Vec norm = getNormale( static_cast(f), &normOK ); - if (!normOK || myNorm.Angle( norm ) <= radianTol) + if (!normOK || isLessAngle( myNorm, norm, cosTol)) { - myCoplanarIDs.insert( f->GetID() ); - faceQueue.push_back( make_pair( f, norm )); + myCoplanarIDs.Add( f->GetID() ); + faceQueue.push_back( std::make_pair( f, norm )); } } } @@ -3056,7 +3086,7 @@ void CoplanarFaces::SetMesh( const SMDS_Mesh* theMesh ) } bool CoplanarFaces::IsSatisfy( long theElementId ) { - return myCoplanarIDs.count( theElementId ); + return myCoplanarIDs.Contains( theElementId ); } /* @@ -3184,14 +3214,13 @@ bool RangeOfIds::SetRangeStr( const TCollection_AsciiString& theStr ) myIds.Clear(); TCollection_AsciiString aStr = theStr; - //aStr.RemoveAll( ' ' ); - //aStr.RemoveAll( '\t' ); for ( int i = 1; i <= aStr.Length(); ++i ) - if ( isspace( aStr.Value( i ))) - aStr.SetValue( i, ','); - - for ( int aPos = aStr.Search( ",," ); aPos != -1; aPos = aStr.Search( ",," ) ) - aStr.Remove( aPos, 1 ); + { + char c = aStr.Value( i ); + if ( !isdigit( c ) && c != ',' && c != '-' ) + aStr.SetValue( i, ' '); + } + aStr.RemoveAll( ' ' ); TCollection_AsciiString tmpStr = aStr.Token( ",", 1 ); int i = 1; @@ -3667,7 +3696,7 @@ bool ManifoldPart::process() myMapIds.Add( aFaceId ); } - if ( fi == ( myAllFacePtr.size() - 1 ) ) + if ( fi == int( myAllFacePtr.size() - 1 )) fi = 0; } // end run on vector of faces return !myMapIds.IsEmpty(); @@ -4458,6 +4487,7 @@ bool BelongToGeom::IsSatisfy (long theId) case SMDS_TOP_FACE : return ( IsContains( myMeshDS,myShape,aNode,TopAbs_FACE )); case SMDS_TOP_3DSPACE: return ( IsContains( myMeshDS,myShape,aNode,TopAbs_SOLID ) || IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL )); + default:; } } } @@ -4483,6 +4513,7 @@ bool BelongToGeom::IsSatisfy (long theId) case SMDSAbs_Face : return ( IsContains( myMeshDS,myShape,anElem,TopAbs_FACE )); case SMDSAbs_Volume: return ( IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID )|| IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )); + default:; } } }