Salome HOME
#19765 EDF 21730 - long time to load med file file with huge amount of groups
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Measurements.cxx
index 8e19cddcaa8afff01f0893db9d55cfd7885da656..a2373378e2f40088b76213abf6d48e9a3b4c0ff2 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020  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
@@ -173,11 +173,11 @@ SMESHGUI_MinDistance::SMESHGUI_MinDistance( QWidget* parent )
   aSOrigin->setChecked( true );
 #ifndef MINDIST_ENABLE_ELEMENT
   aFElem->setEnabled( false );   // NOT AVAILABLE YET
-  aSElem->setEnabled( false );   // NOT AVAILABLE YET
+  //aSElem->setEnabled( false );   // NOT AVAILABLE YET
 #endif
 #ifndef MINDIST_ENABLE_OBJECT
   aFObject->setEnabled( false ); // NOT AVAILABLE YET
-  aSObject->setEnabled( false ); // NOT AVAILABLE YET
+  //aSObject->setEnabled( false ); // NOT AVAILABLE YET
 #endif
   myDX->setReadOnly( true );
   myDY->setReadOnly( true );
@@ -361,7 +361,8 @@ void SMESHGUI_MinDistance::createPreview( double x1, double y1, double z1, doubl
   aCellLocationsArray->SetNumberOfComponents( 1 );
   aCellLocationsArray->SetNumberOfTuples( 1 );
   aCells->InitTraversal();
-  for( vtkIdType idType = 0, *pts, npts; aCells->GetNextCell( npts, pts ); idType++ )
+  vtkIdType const *pts(nullptr);
+  for( vtkIdType idType = 0, npts; aCells->GetNextCell( npts, pts ); idType++ )
     aCellLocationsArray->SetValue( idType, aCells->GetTraversalLocation( npts ) );
   aGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells );
   aCellLocationsArray->Delete();
@@ -595,10 +596,14 @@ void SMESHGUI_MinDistance::compute()
     if ( isOrigin ) {
       x2 = y2 = z2 = 0.;
     }
-    else {
+    else if ( mySecond->checkedId() == NodeTgt ) {
       coord = s2->GetMesh()->GetNodeXYZ( result.node2 );
       x2 = coord[0]; y2 = coord[1]; z2 = coord[2];
     }
+    else
+    {
+      x2 = result.maxX; y2 = result.maxY; z2 = result.maxZ; 
+    }
     createPreview( x1, y1, z1, x2, y2, z2 );
     displayPreview();
   }
@@ -890,7 +895,8 @@ void SMESHGUI_BoundingBox::createPreview( double minX, double maxX, double minY,
   aCellLocationsArray->SetNumberOfComponents( 1 );
   aCellLocationsArray->SetNumberOfTuples( 12 );
   aCells->InitTraversal();
-  for( vtkIdType idType = 0, *pts, npts; aCells->GetNextCell( npts, pts ); idType++ )
+  vtkIdType const *pts(nullptr);
+  for( vtkIdType idType = 0, npts; aCells->GetNextCell( npts, pts ); idType++ )
     aCellLocationsArray->SetValue( idType, aCells->GetTraversalLocation( npts ) );
   aGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells );
   aCellLocationsArray->Delete();