From 81bd0885814f1219569c20815ebcaf7346705dbc Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 15 Nov 2016 19:54:27 +0300 Subject: [PATCH] Fix regressions --- src/SMDS/SMDS_MeshNode.cxx | 16 +++---- src/SMDS/SMDS_UnstructuredGrid.cxx | 20 ++++---- src/SMESH/SMESH_Mesh.cxx | 25 +++++++--- src/SMESH/SMESH_subMesh.cxx | 22 ++++++--- src/SMESHDS/SMESHDS_Mesh.cxx | 48 +++++++------------ src/SMESHDS/SMESHDS_SubMesh.cxx | 8 ++++ src/SMESHGUI/SMESHGUI_VTKUtils.cxx | 38 +++++++-------- src/SMESH_I/SMESH_Gen_i.cxx | 2 +- src/StdMeshers/StdMeshers_ProjectionUtils.cxx | 4 +- src/StdMeshers/StdMeshers_ViscousLayers.cxx | 18 +++++-- 10 files changed, 108 insertions(+), 93 deletions(-) diff --git a/src/SMDS/SMDS_MeshNode.cxx b/src/SMDS/SMDS_MeshNode.cxx index 3261897fe..1f49f82dc 100644 --- a/src/SMDS/SMDS_MeshNode.cxx +++ b/src/SMDS/SMDS_MeshNode.cxx @@ -187,16 +187,16 @@ SMDS_ElemIteratorPtr SMDS_MeshNode::GetInverseElementIterator(SMDSAbs_ElementTyp return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type)); } -// Same as GetInverseElementIterator but the create iterator only return +// Same as GetInverseElementIterator but the created iterator only returns // wanted type elements. class SMDS_MeshNode_MyIterator:public SMDS_ElemIterator { private: - SMDS_Mesh* myMesh; - vtkIdType* myCells; - int myNcells; - SMDSAbs_ElementType myType; - int iter; + SMDS_Mesh* myMesh; + vtkIdType* myCells; + int myNcells; + SMDSAbs_ElementType myType; + int iter; vector myFiltCells; public: @@ -206,20 +206,16 @@ public: SMDSAbs_ElementType type): myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0) { - //MESSAGE("myNcells " << myNcells); for (; iterfromVtkToSmds(vtkId); - //MESSAGE("vtkId " << vtkId << " smdsId " << smdsId); const SMDS_MeshElement* elem = myMesh->FindElement(smdsId); if (elem->GetType() == type) myFiltCells.push_back((SMDS_MeshElement*)elem); } myNcells = myFiltCells.size(); - //MESSAGE("myNcells " << myNcells); iter = 0; - //MESSAGE("SMDS_MeshNode_MyIterator (filter) " << ncells << " " << myNcells); } bool more() diff --git a/src/SMDS/SMDS_UnstructuredGrid.cxx b/src/SMDS/SMDS_UnstructuredGrid.cxx index 7e88bd37e..d37eec139 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.cxx +++ b/src/SMDS/SMDS_UnstructuredGrid.cxx @@ -189,13 +189,14 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n // --- if newNodeSize, create a new compacted vtkPoints - vtkPoints *newPoints = vtkPoints::New(); - newPoints->SetDataType(VTK_DOUBLE); - newPoints->SetNumberOfPoints(newNodeSize); - if (newNodeSize) + if ( newNodeSize ) { // rnv: to fix bug "21125: EDF 1233 SMESH: Degradation of precision in a test case for quadratic conversion" // using double type for storing coordinates of nodes instead float. + vtkPoints *newPoints = vtkPoints::New(); + newPoints->SetDataType(VTK_DOUBLE); + newPoints->SetNumberOfPoints(newNodeSize); + int oldNodeSize = idNodesOldToNew.size(); int i = 0; @@ -211,21 +212,16 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n int endBloc = i; copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc); } - newPoints->Squeeze(); - } - - if (1/*newNodeSize*/) - { this->SetPoints(newPoints); + newPoints->Delete(); } - newPoints->Delete(); - + this->Points->Squeeze(); // --- create new compacted Connectivity, Locations and Types int oldCellSize = this->Types->GetNumberOfTuples(); - if ( oldCellSize == newCellSize ) // no holes in elements + if ( !newNodeSize && oldCellSize == newCellSize ) // no holes in elements { this->Connectivity->Squeeze(); this->Locations->Squeeze(); diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index 094dd4fee..a3e707247 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -1242,24 +1242,35 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h } } if ( toNotify ) + { smToNotify.push_back( aSubMesh ); - - if ( !aSubMesh->IsEmpty() && - aSubMesh->GetSubShape().ShapeType() == TopAbs_EDGE && - !toNotify ) - allMeshedEdgesNotified = false; + if ( aSubMesh->GetAlgoState() == SMESH_subMesh::MISSING_HYP ) + allMeshedEdgesNotified = false; // update of algo state needed, not mesh clearing + } + else + { + if ( !aSubMesh->IsEmpty() && + aSubMesh->GetSubShape().ShapeType() == TopAbs_EDGE ) + allMeshedEdgesNotified = false; + } } + if ( smToNotify.empty() ) + return; // if all meshed EDGEs will be notified then the notification is equivalent // to the whole mesh clearing if ( allMeshedEdgesNotified ) - Clear(); + { + if ( NbNodes() > 0 ) + Clear(); + } else + { // notify in reverse order to avoid filling of the pool of IDs for ( int i = smToNotify.size()-1; i >= 0; --i ) smToNotify[i]->AlgoStateEngine(SMESH_subMesh::MODIF_HYP, const_cast< SMESH_Hypothesis*>( hyp )); - + } HasModificationsToDiscard(); // to reset _isModified flag if mesh becomes empty GetMeshDS()->Modified(); } diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index fdea4fed2..19f10229a 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -1279,24 +1279,34 @@ static void cleanSubMesh( SMESH_subMesh * subMesh ) if ( nbElems > 0 ) { // start from elem with max ID to avoid filling the pool of IDs - const SMDS_MeshElement * lastElem = subMeshDS->GetElement( nbElems-1 ); - bool rev = ( lastElem->GetID() == meshDS->MaxElementID() ); + bool rev = true; SMDS_ElemIteratorPtr ite = subMeshDS->GetElements( rev ); + const SMDS_MeshElement * lastElem = ite->next(); + rev = ( lastElem->GetID() == meshDS->MaxElementID() ); + if ( !rev ) + ite = subMeshDS->GetElements( rev ); + else + meshDS->RemoveFreeElement( lastElem, subMeshDS ); while (ite->more()) { const SMDS_MeshElement * elt = ite->next(); - meshDS->RemoveFreeElement(elt, 0); + meshDS->RemoveFreeElement( elt, subMeshDS ); } } int nbNodes = subMeshDS->NbNodes(); if ( nbNodes > 0 ) { - const SMDS_MeshNode * lastNode = subMeshDS->GetNode( nbNodes-1 ); - bool rev = ( lastNode->GetID() == meshDS->MaxNodeID() ); + bool rev = true; SMDS_NodeIteratorPtr itn = subMeshDS->GetNodes( rev ); + const SMDS_MeshNode * lastNode = itn->next(); + rev = ( lastNode->GetID() == meshDS->MaxNodeID() ); + if ( !rev ) + itn = subMeshDS->GetNodes( rev ); + else + meshDS->RemoveNode( lastNode ); while (itn->more()) { const SMDS_MeshNode * node = itn->next(); if ( node->NbInverseElements() == 0 ) - meshDS->RemoveFreeNode(node, 0); + meshDS->RemoveFreeNode( node, subMeshDS ); else // for StdMeshers_CompositeSegment_1D: node in one submesh, edge in another meshDS->RemoveNode(node); } diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index ad235f0b8..bdd2239d1 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -2150,14 +2150,10 @@ void SMESHDS_Mesh::compactMesh() SMDS_Mesh::compactMesh(); int newNodeSize = 0; - int nbNodes = myNodes.size(); - int nbVtkNodes = myGrid->GetNumberOfPoints(); - int nbNodeTemp = nbVtkNodes; - if (nbNodes > nbVtkNodes) - nbNodeTemp = nbNodes; - vector idNodesOldToNew; - idNodesOldToNew.clear(); - idNodesOldToNew.resize(nbNodeTemp, -1); // all unused id will be -1 + int nbNodes = myNodes.size(); + int nbVtkNodes = myGrid->GetNumberOfPoints(); + int nbNodeTemp = Max( nbVtkNodes, nbNodes ); + vector idNodesOldToNew(nbNodeTemp, -1); // all unused id will be -1 for (int i = 0; i < nbNodes; i++) { @@ -2168,18 +2164,14 @@ void SMESHDS_Mesh::compactMesh() newNodeSize++; } } - bool areNodesModified = (newNodeSize < nbVtkNodes); + bool areNodesModified = (newNodeSize != nbVtkNodes); areNodesModified = true; int newCellSize = 0; - int nbCells = myCells.size(); - int nbVtkCells = myGrid->GetNumberOfCells(); - int nbCellTemp = nbVtkCells; - if (nbCells > nbVtkCells) - nbCellTemp = nbCells; - vector idCellsOldToNew; - idCellsOldToNew.clear(); - idCellsOldToNew.resize(nbCellTemp, -1); // all unused id will be -1 + int nbCells = myCells.size(); + int nbVtkCells = myGrid->GetNumberOfCells(); + int nbCellTemp = Max( nbVtkCells, nbCells ); + vector idCellsOldToNew(nbCellTemp, -1); // all unused id will be -1 for (int i = 0; i < nbCells; i++) { @@ -2206,18 +2198,17 @@ void SMESHDS_Mesh::compactMesh() if (nbVtkCells > newCellSize) newCellSize = nbVtkCells; // several cells with same SMDS Id } - // --- SMDS_MeshNode and myNodes (id in SMDS and in VTK are the same), myNodeIdFactory + // --- SMDS_MeshNode and myNodes, myNodeIdFactory - if (areNodesModified) + if ( true ) { - SetOfNodes newNodes; - newNodes.resize(newNodeSize+1,0); // 0 not used, SMDS numbers 1..n + SetOfNodes newNodes(newNodeSize+1,0); // 0 not used, SMDS numbers 1..n int newSmdsId = 0; for (int i = 0; i < nbNodes; i++) { if (myNodes[i]) { - newSmdsId++; // SMDS id start to 1 + newSmdsId++; // SMDS id starts from 1 int oldVtkId = myNodes[i]->getVtkId(); int newVtkId = idNodesOldToNew[oldVtkId]; myNodes[i]->setVtkId(newVtkId); @@ -2232,25 +2223,18 @@ void SMESHDS_Mesh::compactMesh() // --- SMDS_MeshCell, myCellIdVtkToSmds, myCellIdSmdsToVtk, myCells int vtkIndexSize = myCellIdVtkToSmds.size(); - int maxVtkId = -1; for (int oldVtkId = 0; oldVtkId < vtkIndexSize; oldVtkId++) { int oldSmdsId = this->myCellIdVtkToSmds[oldVtkId]; if (oldSmdsId > 0) { int newVtkId = idCellsOldToNew[oldVtkId]; - if (newVtkId > maxVtkId) - maxVtkId = newVtkId; myCells[oldSmdsId]->setVtkId(newVtkId); } } - SetOfCells newCells; - vector newVtkToSmds; - - assert(maxVtkId < newCellSize); - newCells.resize(newCellSize+1, 0); // 0 not used, SMDS numbers 1..n - newVtkToSmds.resize(newCellSize+1, -1); + SetOfCells newCells(newCellSize+1, 0); // 0 not used, SMDS numbers 1..n + vector newVtkToSmds(newCellSize+1, -1); int myCellsSize = myCells.size(); int newSmdsId = 0; @@ -2258,7 +2242,7 @@ void SMESHDS_Mesh::compactMesh() { if ( myCells[i] ) { - newSmdsId++; // SMDS id start to 1 + newSmdsId++; // SMDS id starts from 1 assert(newSmdsId <= newCellSize); newCells[newSmdsId] = myCells[i]; newCells[newSmdsId]->setId(newSmdsId); diff --git a/src/SMESHDS/SMESHDS_SubMesh.cxx b/src/SMESHDS/SMESHDS_SubMesh.cxx index d3b412275..892873016 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.cxx +++ b/src/SMESHDS/SMESHDS_SubMesh.cxx @@ -567,6 +567,10 @@ void SMESHDS_SubMesh::compactList() myElements.swap(newElems); myUnusedIdElements = 0; } + else + { + std::vector( myElements ).swap( myElements ); + } if ( myUnusedIdNodes > 0 ) { @@ -582,6 +586,10 @@ void SMESHDS_SubMesh::compactList() myNodes.swap(newNodes); myUnusedIdNodes = 0; } + else + { + std::vector( myNodes ).swap( myNodes ); + } } //======================================================================= diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index 390335532..bd52efd4b 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -349,7 +349,7 @@ namespace SMESH try { OCC_CATCH_SIGNALS; if (nulData) - objModified = aVisualObj->NulData(); + objModified = aVisualObj->NulData(); else objModified = aVisualObj->Update(); } @@ -370,24 +370,24 @@ namespace SMESH int usedMB = aVisualObj->GetUnstructuredGrid()->GetActualMemorySize() / 1024; //MESSAGE("SMESHGUI_VTKUtils::GetVisualObj(), freeMB=" << freeMB << ", usedMB=" < 0 && usedMB * 5 > freeMB ) { - bool continu = false; - if ( usedMB * 3 > freeMB ) - // even dont try to show - SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"), - QObject::tr("SMESH_NO_MESH_VISUALIZATION")); - else - // there is a chance to succeed - continu = SUIT_MessageBox::warning - (SMESHGUI::desktop(), - QObject::tr("SMESH_WRN_WARNING"), - QObject::tr("SMESH_CONTINUE_MESH_VISUALIZATION"), - SUIT_MessageBox::Yes | SUIT_MessageBox::No, - SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes; - if ( !continu ) { - // remove the corresponding actors from all views - RemoveVisualObjectWithActors( theEntry ); - aVisualObj.reset(); - } + bool continu = false; + if ( usedMB * 3 > freeMB ) + // even dont try to show + SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"), + QObject::tr("SMESH_NO_MESH_VISUALIZATION")); + else + // there is a chance to succeed + continu = SUIT_MessageBox::warning + (SMESHGUI::desktop(), + QObject::tr("SMESH_WRN_WARNING"), + QObject::tr("SMESH_CONTINUE_MESH_VISUALIZATION"), + SUIT_MessageBox::Yes | SUIT_MessageBox::No, + SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes; + if ( !continu ) { + // remove the corresponding actors from all views + RemoveVisualObjectWithActors( theEntry ); + aVisualObj.reset(); + } } } diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 72540ef32..6371c3806 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -960,7 +960,7 @@ void SMESH_Gen_i::SetOption(const char* name, const char* value) { vector color; string str = value; - // color must be presented as a string of next form: + // color must be presented as a string of following form: if ( str.at(0) == '#' && str.length() == 7 ) { // hexadecimal color ("#ffaa00", for example) str = str.substr(1); for ( size_t i = 0; i < str.length()/2; i++ ) diff --git a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx index c4b082adc..c13ea9fcb 100644 --- a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx +++ b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx @@ -2324,7 +2324,7 @@ bool StdMeshers_ProjectionUtils::MakeComputed(SMESH_subMesh * sm, const int iter string algoType = algo->GetName(); if ( algoType.substr(0, 11) != "Projection_") - return gen->Compute( *mesh, shape, /*shapeOnly=*/true ); + return gen->Compute( *mesh, shape, SMESH_Gen::SHAPE_ONLY ); // try to compute source mesh @@ -2365,7 +2365,7 @@ bool StdMeshers_ProjectionUtils::MakeComputed(SMESH_subMesh * sm, const int iter srcMesh = mesh; if ( MakeComputed( srcMesh->GetSubMesh( srcShape ), iterationNb + 1 ) && - gen->Compute( *mesh, shape, /*shapeOnly=*/true )) + gen->Compute( *mesh, shape, SMESH_Gen::SHAPE_ONLY )) return sm->IsMeshComputed(); return false; diff --git a/src/StdMeshers/StdMeshers_ViscousLayers.cxx b/src/StdMeshers/StdMeshers_ViscousLayers.cxx index 1ebf95af9..393e2799c 100644 --- a/src/StdMeshers/StdMeshers_ViscousLayers.cxx +++ b/src/StdMeshers/StdMeshers_ViscousLayers.cxx @@ -5653,20 +5653,30 @@ bool _Smoother1D::smoothComplexEdge( _SolidData& data, return false; } + // adjust length of extreme LE (test viscous_layers_01/B7) + gp_Vec vDiv0( pExtreme[0], pProj[0] ); + gp_Vec vDiv1( pExtreme[1], pProj[1] ); + double d0 = vDiv0.Magnitude(); + double d1 = vDiv1.Magnitude(); + if ( e[0]->_normal * vDiv0.XYZ() < 0 ) e[0]->_len += d0; + else e[0]->_len -= d0; + if ( e[1]->_normal * vDiv1.XYZ() < 0 ) e[1]->_len += d1; + else e[1]->_len -= d1; + // compute normalized length of the offset segments located between the projections size_t iSeg = 0, nbSeg = _iSeg[1] - _iSeg[0] + 1; vector< double > len( nbSeg + 1 ); len[ iSeg++ ] = 0; - len[ iSeg++ ] = pProj[ 0 ].Distance( _offPoints[ _iSeg[0]+1 ]._xyz ); + len[ iSeg++ ] = pProj[ 0 ].Distance( _offPoints[ _iSeg[0]+1 ]._xyz )/* * e[0]->_lenFactor*/; for ( size_t i = _iSeg[0]+1; i <= _iSeg[1]; ++i, ++iSeg ) { len[ iSeg ] = len[ iSeg-1 ] + _offPoints[i].Distance( _offPoints[i+1] ); } - len[ nbSeg ] -= pProj[ 1 ].Distance( _offPoints[ _iSeg[1]+1 ]._xyz ); + len[ nbSeg ] -= pProj[ 1 ].Distance( _offPoints[ _iSeg[1]+1 ]._xyz )/* * e[1]->_lenFactor*/; - double d0 = pProj[0].Distance( pExtreme[0]); - double d1 = pProj[1].Distance( pExtreme[1]); + // d0 *= e[0]->_lenFactor; + // d1 *= e[1]->_lenFactor; double fullLen = len.back() - d0 - d1; for ( iSeg = 0; iSeg < len.size(); ++iSeg ) len[iSeg] = ( len[iSeg] - d0 ) / fullLen; -- 2.30.2