]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Fix regression of SALOME_TESTS/Grids/smesh/3D_mesh_Extrusion_01/B2
authoreap <eap@opencascade.com>
Thu, 1 Sep 2016 17:47:02 +0000 (20:47 +0300)
committereap <eap@opencascade.com>
Thu, 1 Sep 2016 17:47:02 +0000 (20:47 +0300)
   (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

src/OBJECT/SMESH_Object.cxx
src/SMDS/SMDS_UnstructuredGrid.cxx
src/SMESH/SMESH_MeshEditor.cxx
src/SMESHDS/SMESHDS_Mesh.cxx
src/SMESHGUI/SMESHGUI.cxx
src/StdMeshers/StdMeshers_Prism_3D.cxx

index 61b36a78c706f0b5270700ee4678bd80994a9b19..520abe33550aaffcc59c8f0dfea99bdd8477a3db 100644 (file)
@@ -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();
index b3f743a4fec5ea4242f45c266a4dcb2a397f3a03..808d809a1e962063af66d0424aa6f20203782d8e 100644 (file)
@@ -155,26 +155,33 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& 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<int>& 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<int>& idNodesOldToNew, int n
     this->SetCells(newTypes, newLocations, newConnectivity, FaceLocations, Faces);
   }
 
-  newPoints->Delete();
   newTypes->Delete();
   newLocations->Delete();
   newConnectivity->Delete();
index 1f4f4289191dc22b8965870804f80c9a7f8e70c4..faeeefc012d8b5c653840f567cafde0f25c944ab 100644 (file)
@@ -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 );
index 7c233db58e7c600d57822f4c449c121d2103fb61..168b9ceb3a7c8f8552a75d0d03a5fd23f03b76c8 100644 (file)
@@ -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;
 }
 
index cd4da8a73faeb2b6cc6faad164f1d0ccf4bcdcab..082159299d77fa19a1733d6d56aba1cf7431c738 100644 (file)
@@ -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 );
 
index fe5276b3993ba46566cef617e7bc725a195ff9c1..5734c02e99354a81c2242fb804dc4edc558be3b0 100644 (file)
@@ -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<const SMDS_MeshNode*> 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;
 }