From: eap Date: Thu, 1 Sep 2016 17:47:02 +0000 (+0300) Subject: Fix regression of SALOME_TESTS/Grids/smesh/3D_mesh_Extrusion_01/B2 X-Git-Tag: V8_1_0rc1~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8a1ff9ba77b7b72b64b08134f941b56aac80ff55;p=modules%2Fsmesh.git Fix regression of SALOME_TESTS/Grids/smesh/3D_mesh_Extrusion_01/B2 (StdMeshers_Prism_3D.cxx) + small optimization of SMDS_UnstructuredGrid::compactGrid() (SMDS_UnstructuredGrid.cxx, SMESH_Object.cxx) - de-allocate old data as soon as possible, not at the and of compacting + some minor changes --- diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index 61b36a78c..520abe335 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -280,6 +280,7 @@ void SMESH_VisualObjDef::buildPrs(bool buildGrid) myLocalGrid = false; if (!GetMesh()->isCompacted()) { + NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in compactMesh() if ( MYDEBUG ) MESSAGE("*** buildPrs ==> compactMesh!"); GetMesh()->compactMesh(); } @@ -570,6 +571,7 @@ vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid() { if ( !myLocalGrid && !GetMesh()->isCompacted() ) { + NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in compactMesh() GetMesh()->compactMesh(); updateEntitiesFlags(); vtkUnstructuredGrid *theGrid = GetMesh()->getGrid(); diff --git a/src/SMDS/SMDS_UnstructuredGrid.cxx b/src/SMDS/SMDS_UnstructuredGrid.cxx index b3f743a4f..808d809a1 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.cxx +++ b/src/SMDS/SMDS_UnstructuredGrid.cxx @@ -155,26 +155,33 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n newPoints->SetDataType(VTK_DOUBLE); newPoints->SetNumberOfPoints(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. - int oldNodeSize = idNodesOldToNew.size(); + { + // 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. + int oldNodeSize = idNodesOldToNew.size(); - int i = 0; - while ( i < oldNodeSize ) - { - // skip a hole if any - while ( i < oldNodeSize && idNodesOldToNew[i] < 0 ) - ++i; - int startBloc = i; - // look for a block end - while ( i < oldNodeSize && idNodesOldToNew[i] >= 0 ) - ++i; - int endBloc = i; - copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc); - } - newPoints->Squeeze(); + int i = 0; + while ( i < oldNodeSize ) + { + // skip a hole if any + while ( i < oldNodeSize && idNodesOldToNew[i] < 0 ) + ++i; + int startBloc = i; + // look for a block end + while ( i < oldNodeSize && idNodesOldToNew[i] >= 0 ) + ++i; + int endBloc = i; + copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc); } + newPoints->Squeeze(); + } + + if (1/*newNodeSize*/) + { + this->SetPoints(newPoints); + } + newPoints->Delete(); + // --- create new compacted Connectivity, Locations and Types @@ -218,11 +225,6 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n } newConnectivity->Squeeze(); - if (1/*newNodeSize*/) - { - this->SetPoints(newPoints); - } - if (vtkDoubleArray* diameters = vtkDoubleArray::SafeDownCast( vtkDataSet::CellData->GetScalars() )) // Balls { @@ -282,7 +284,6 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n this->SetCells(newTypes, newLocations, newConnectivity, FaceLocations, Faces); } - newPoints->Delete(); newTypes->Delete(); newLocations->Delete(); newConnectivity->Delete(); diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 1f4f42891..faeeefc01 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -3994,11 +3994,11 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems, fToler2 = BRep_Tool::Tolerance( face ); fToler2 *= fToler2 * 10.; isUPeriodic = surface->IsUPeriodic(); - if ( isUPeriodic ) - surface->UPeriod(); + // if ( isUPeriodic ) + // surface->UPeriod(); isVPeriodic = surface->IsVPeriodic(); - if ( isVPeriodic ) - surface->VPeriod(); + // if ( isVPeriodic ) + // surface->VPeriod(); surface->Bounds( u1, u2, v1, v2 ); helper.SetSubShape( face ); } @@ -4057,9 +4057,9 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems, { // check if all faces around the node are on faceSubMesh // because a node on edge may be bound to face - SMDS_ElemIteratorPtr eIt = node->GetInverseElementIterator(SMDSAbs_Face); bool all = true; if ( faceSubMesh ) { + SMDS_ElemIteratorPtr eIt = node->GetInverseElementIterator(SMDSAbs_Face); while ( eIt->more() && all ) { const SMDS_MeshElement* e = eIt->next(); all = faceSubMesh->Contains( e ); diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index 7c233db58..168b9ceb3 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -1398,11 +1398,7 @@ int SMESHDS_Mesh::MaxSubMeshIndex() const //======================================================================= int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const { - if (myShape.IsNull()) - MESSAGE("myShape is NULL"); - int index = myIndexToShape.FindIndex(S); - return index; } diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index cd4da8a73..082159299 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -975,6 +975,7 @@ namespace aSel->selectedObjects( selected ); if ( selected.Extent() >= 1 ) { + SUIT_OverrideCursor wc; SALOME_ListIteratorOfListIO It( selected ); for( ; It.More(); It.Next()){ Handle(SALOME_InteractiveObject) IObject = It.Value(); @@ -1595,6 +1596,7 @@ namespace return; } // case SMESHOp::OpProperties: } // switch(theCommandID) + SUIT_OverrideCursor wc; SALOME_ListIteratorOfListIO It( selected ); for( ; It.More(); It.Next()){ Handle(SALOME_InteractiveObject) IObject = It.Value(); @@ -2599,6 +2601,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case SMESHOp::OpOrientationOnFaces: { + SUIT_OverrideCursor wc; LightApp_SelectionMgr* mgr = selectionMgr(); SALOME_ListIO selected; mgr->selectedObjects( selected ); diff --git a/src/StdMeshers/StdMeshers_Prism_3D.cxx b/src/StdMeshers/StdMeshers_Prism_3D.cxx index fe5276b39..5734c02e9 100644 --- a/src/StdMeshers/StdMeshers_Prism_3D.cxx +++ b/src/StdMeshers/StdMeshers_Prism_3D.cxx @@ -162,6 +162,12 @@ namespace { { return _src2tgtNodes; } + void SetEventListener( SMESH_subMesh* tgtSubMesh ) + { + NSProjUtils::SetEventListener( tgtSubMesh, + _sourceHypo->GetSourceFace(), + _sourceHypo->GetSourceMesh() ); + } }; //======================================================================= /*! @@ -2265,29 +2271,39 @@ bool StdMeshers_Prism_3D::projectBottomToTop( const gp_Trsf & bottom Handle(Geom_Surface) surface = BRep_Tool::Surface( topFace, loc ); bool isPlanar = GeomLib_IsPlanarSurface( surface ).IsPlanar(); - bool isFixed = false; set fixedNodes; - for ( int iAttemp = 0; !isFixed && iAttemp < 10; ++iAttemp ) - { - TIDSortedElemSet faces; - for ( faceIt = topSMDS->GetElements(); faceIt->more(); ) - faces.insert( faces.end(), faceIt->next() ); + TIDSortedElemSet faces; + for ( faceIt = topSMDS->GetElements(); faceIt->more(); ) + faces.insert( faces.end(), faceIt->next() ); + bool isOk = false; + for ( int isCentroidal = 0; isCentroidal < 2; ++isCentroidal ) + { SMESH_MeshEditor::SmoothMethod algo = - iAttemp ? SMESH_MeshEditor::CENTROIDAL : SMESH_MeshEditor::LAPLACIAN; + isCentroidal ? SMESH_MeshEditor::CENTROIDAL : SMESH_MeshEditor::LAPLACIAN; + + int nbAttempts = isCentroidal ? 1 : 10; + for ( int iAttemp = 0; iAttemp < nbAttempts; ++iAttemp ) + { + TIDSortedElemSet workFaces = faces; - // smoothing - editor.Smooth( faces, fixedNodes, algo, /*nbIterations=*/ 10, - /*theTgtAspectRatio=*/1.0, /*the2D=*/!isPlanar); + // smoothing + editor.Smooth( workFaces, fixedNodes, algo, /*nbIterations=*/ 10, + /*theTgtAspectRatio=*/1.0, /*the2D=*/!isPlanar); - isFixed = !topHelper.IsDistorted2D( topSM, /*checkUV=*/true ); + if (( isOk = !topHelper.IsDistorted2D( topSM, /*checkUV=*/true )) && + ( !isCentroidal )) + break; + } } - if ( !isFixed ) + if ( !isOk ) return toSM( error( TCom("Projection from face #") << botSM->GetId() << " to face #" << topSM->GetId() << " failed: inverted elements created")); } + TProjction2dAlgo::instance( this )->SetEventListener( topSM ); + return true; } @@ -2426,6 +2442,8 @@ bool StdMeshers_Prism_3D::project2dMesh(const TopoDS_Face& theSrcFace, tgtSM->ComputeStateEngine ( SMESH_subMesh::CHECK_COMPUTE_STATE ); tgtSM->ComputeSubMeshStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE ); + projector2D->SetEventListener( tgtSM ); + return ok; }