Salome HOME
[bos #40653][CEA] New mesh import export formats with meshio.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ComputeDlg.cxx
index a40bac0d4053ce841deac240e6f86ad10f518b22..039a7cde27c92491bf39e3a770b24878b90dad0f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -575,11 +575,7 @@ QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent, bool ForEval)
   myTable->hideColumn( COL_PUBLISHED );
   myTable->hideColumn( COL_SHAPEID );
   myTable->hideColumn( COL_BAD_MESH );
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-  myTable->horizontalHeader()->setResizeMode( COL_ERROR, QHeaderView::Interactive );
-#else
   myTable->horizontalHeader()->setSectionResizeMode( COL_ERROR, QHeaderView::Interactive );
-#endif
   myTable->setWordWrap( true );
   myTable->horizontalHeader()->setStretchLastSection( true );
   myTable->setMinimumWidth( 500 );
@@ -660,6 +656,24 @@ SMESHGUI_BaseComputeOp::SMESHGUI_BaseComputeOp()
   myHelpFileName = "about_meshes.html"; // V4
 }
 
+//================================================================================
+/*!
+ * \brief Gets dialog of this operation
+ * \retval LightApp_Dialog* - pointer to dialog of this operation
+ */
+//================================================================================
+
+LightApp_Dialog* SMESHGUI_BaseComputeOp::dlg() const
+{
+  return myCompDlg;
+}
+
+//================================================================================
+/*!
+ * \brief Return a selected mesh
+ */
+//================================================================================
+
 SMESH::SMESH_Mesh_ptr SMESHGUI_BaseComputeOp::getMesh()
 {
   LightApp_SelectionMgr* Sel = selectionMgr();
@@ -669,6 +683,23 @@ SMESH::SMESH_Mesh_ptr SMESHGUI_BaseComputeOp::getMesh()
   return myMesh->_is_nil() ? aMesh._retn() : SMESH::SMESH_Mesh::_duplicate( myMesh );
 }
 
+//================================================================================
+/*!
+ * \brief check the same operations on the same mesh
+ */
+//================================================================================
+
+bool SMESHGUI_BaseComputeOp::isValid(  SUIT_Operation* theOp  ) const
+{
+  SMESHGUI_BaseComputeOp* baseOp = dynamic_cast<SMESHGUI_BaseComputeOp*>( theOp );
+  bool ret = true;
+  if ( !myMesh->_is_nil() && baseOp ) {
+    SMESH::SMESH_Mesh_var aMesh = baseOp->getMesh();
+    if ( !aMesh->_is_nil() && aMesh->GetId() == myMesh->GetId() ) ret = false;
+  }
+  return ret;
+}
+
 //================================================================================
 /*!
  * \brief Start operation
@@ -724,6 +755,8 @@ void SMESHGUI_BaseComputeOp::startOperation()
     return;
   }
 
+  myCompDlg->myMeshName->setText( SMESH::GetName( myIObject ));
+
   myMainShape = myMesh->GetShapeToMesh();
 
   SMESHGUI_Operation::startOperation();
@@ -863,6 +896,56 @@ void SMESHGUI_ComputeDlg_QThreadQDialog::closeEvent(QCloseEvent *event)
   event->accept();
 }
 
+//================================================================================
+void SMESHGUI_BaseComputeOp::logMeshSize()
+{
+  if(myMesh->_is_nil())
+  {
+    return;
+  }
+
+  SMESH::smIdType_array_var aRes = myMesh->GetMeshInfo();
+  QString aMessage = QString("%1").arg( aRes[SMDSAbs_EntityType::SMDSEntity_Node]) + " nodes";
+  CAM_Application::logStructuredUserEvent("Mesh",
+                                          "Result size",
+                                          "",
+                                          "",
+                                          aMessage);
+  
+  int nbEdges = aRes[SMDSAbs_EntityType::SMDSEntity_Edge] + aRes[SMDSAbs_EntityType::SMDSEntity_Quad_Edge];
+  aMessage = QString("%1").arg(nbEdges) + " edges";
+  CAM_Application::logStructuredUserEvent("Mesh",
+                                          "Result size",
+                                          "",
+                                          "",
+                                          aMessage);
+  
+  int nbFaces = aRes[SMDSAbs_EntityType::SMDSEntity_Triangle] + aRes[SMDSAbs_EntityType::SMDSEntity_Quad_Triangle] +
+                aRes[SMDSAbs_EntityType::SMDSEntity_BiQuad_Triangle] + aRes[SMDSAbs_EntityType::SMDSEntity_Quadrangle] +
+                aRes[SMDSAbs_EntityType::SMDSEntity_Quad_Quadrangle] + aRes[SMDSAbs_EntityType::SMDSEntity_BiQuad_Quadrangle] +
+                aRes[SMDSAbs_EntityType::SMDSEntity_Polygon] + aRes[SMDSAbs_EntityType::SMDSEntity_Quad_Polygon];
+  aMessage = QString("%1").arg(nbFaces) + " faces";
+  CAM_Application::logStructuredUserEvent("Mesh",
+                                          "Result size",
+                                          "",
+                                          "",
+                                          aMessage);
+  
+  int nbVolumes = aRes[SMDSAbs_EntityType::SMDSEntity_Tetra] + aRes[SMDSAbs_EntityType::SMDSEntity_Quad_Tetra] +
+                  aRes[SMDSAbs_EntityType::SMDSEntity_Pyramid] + aRes[SMDSAbs_EntityType::SMDSEntity_Quad_Pyramid] +
+                  aRes[SMDSAbs_EntityType::SMDSEntity_Hexa] + aRes[SMDSAbs_EntityType::SMDSEntity_Quad_Hexa] +
+                  aRes[SMDSAbs_EntityType::SMDSEntity_TriQuad_Hexa] + aRes[SMDSAbs_EntityType::SMDSEntity_Penta] +
+                  aRes[SMDSAbs_EntityType::SMDSEntity_Quad_Penta] + aRes[SMDSAbs_EntityType::SMDSEntity_BiQuad_Penta] +
+                  aRes[SMDSAbs_EntityType::SMDSEntity_Hexagonal_Prism] + aRes[SMDSAbs_EntityType::SMDSEntity_Polyhedra];
+  aMessage = QString("%1").arg(nbVolumes) + " volumes";
+  CAM_Application::logStructuredUserEvent("Mesh",
+                                          "Result size",
+                                          "",
+                                          "",
+                                          aMessage);
+
+}
+
 //================================================================================
 /*!
  * \brief computeMesh()
@@ -887,7 +970,6 @@ void SMESHGUI_BaseComputeOp::computeMesh()
   bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
   if ( shapeOK )
   {
-    myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
     SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
     SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
     if ( errors->length() > 0 ) {
@@ -955,7 +1037,7 @@ void SMESHGUI_BaseComputeOp::computeMesh()
           SMESH::SMESH_IDSource_var aSubMeshObj =
             SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( smSObj );
           SMESH_Actor *anActor = SMESH::FindActorByObject( aSubMeshObj );
-          if ( anActor && anActor->GetVisibility() )
+          if ( anActor /*&& anActor->GetVisibility()*/ )
             aListToUpdate.append( TListOf_IDSrc_SObj::value_type( aSubMeshObj, smSObj ));
         }
         // put Groups into list
@@ -971,7 +1053,7 @@ void SMESHGUI_BaseComputeOp::computeMesh()
           SMESH::SMESH_IDSource_var aGroupObj =
             SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aGroupSO );
           SMESH_Actor *anActor = SMESH::FindActorByObject( aGroupObj );
-          if ( anActor && anActor->GetVisibility() )
+          if ( anActor /*&& anActor->GetVisibility()*/ )
             aListToUpdate.append( TListOf_IDSrc_SObj::value_type( aGroupObj, aGroupSO ));
         }
 
@@ -987,22 +1069,25 @@ void SMESHGUI_BaseComputeOp::computeMesh()
           {
             try {
               OCC_CATCH_SIGNALS;
-              bool toDisplay = false;
+              std::string entry = (*anIter).second->GetID();
               if ( !aMesh->_is_nil() ) // display only a mesh
               {
-                toDisplay = true;
                 SMESH_Actor *anActor = SMESH::FindActorByObject( aMesh );
-                if ( !anActor ) anActor = SMESH::CreateActor( (*anIter).second->GetID().c_str(),
-                                                              /*clearLog =*/ true );
+                if ( !anActor ) anActor = SMESH::CreateActor( entry.c_str(), /*clearLog =*/true );
                 if ( anActor ) // actor is not created for an empty mesh
                 {
                   anActor->SetEntityMode( entities );
-                  SMESH::DisplayActor( SMESH::GetActiveWindow(), anActor );
+                  //SMESH::DisplayActor( SMESH::GetActiveWindow(), anActor ); -- 23615
                 }
               }
-              Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
-                ( (*anIter).second->GetID().c_str(), "SMESH", (*anIter).second->GetName().c_str() );
-              SMESH::Update(anIO, toDisplay);
+              else
+              {
+                SMESH_Actor *anActor = SMESH::FindActorByEntry( entry.c_str() );
+                anActor->Update();
+                if ( !anActor->GetVisibility() )
+                  continue;
+              }
+              SMESH::UpdateView( SMESH::eDisplay, entry.c_str() );
 
               if ( SVTK_ViewWindow* vtkWnd = SMESH::GetVtkViewWindow(SMESH::GetActiveWindow() ))
                 if ( vtkWnd->getRenderer() )
@@ -1025,9 +1110,9 @@ void SMESHGUI_BaseComputeOp::computeMesh()
               }
             }
             catch (...) {
-#ifdef _DEBUG_
+
               MESSAGE ( "Exception thrown during mesh visualization" );
-#endif
+
               if ( SMDS_Mesh::CheckMemory(true) ) { // has memory to show warning?
                 SMESH::OnVisuException();
               }
@@ -1087,9 +1172,13 @@ void SMESHGUI_BaseComputeOp::computeMesh()
     isShowResultDlg = true;
   }
 
+  //log Mesh size info
+  logMeshSize();
+
   // SHOW RESULTS
   if ( isShowResultDlg )
     showComputeResult( memoryLack, noCompError,aCompErrors, noHypoError, aHypErrors );
+
 }
 
 void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack,
@@ -1112,7 +1201,7 @@ void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack,
   }
   else if ( theNoCompError && theNoHypoError )
   {
-    SMESH::long_array_var aRes = myMesh->GetMeshInfo();
+    SMESH::smIdType_array_var aRes = myMesh->GetMeshInfo();
     aCompDlg->myFullInfo->SetMeshInfo( aRes );
     aCompDlg->myFullInfo->show();
     aCompDlg->myBriefInfo->hide();
@@ -1127,7 +1216,7 @@ void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack,
                        theCompErrors[ i ].code == SMESH::COMPERR_NO_MESH_ON_SHAPE );
 
     // full or brief mesh info
-    SMESH::long_array_var aRes = myMesh->GetMeshInfo();
+    SMESH::smIdType_array_var aRes = myMesh->GetMeshInfo();
     if ( onlyWarnings ) {
       aCompDlg->myFullInfo->SetMeshInfo( aRes );
       aCompDlg->myFullInfo->show();
@@ -1138,7 +1227,7 @@ void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack,
       aCompDlg->myFullInfo->hide();
     }
 
-    // pbs of hypo dfinitions
+    // pbs of hypo definitions
     if ( theNoHypoError ) {
       aCompDlg->myHypErrorGroup->hide();
     } else {
@@ -1259,8 +1348,8 @@ void SMESHGUI_BaseComputeOp::stopOperation()
 
 void SMESHGUI_BaseComputeOp::onPublishShape()
 {
-  GEOM::GEOM_Gen_var      geomGen = SMESH::GetGEOMGen();
   GEOM::GEOM_Object_var meshShape = myMesh->GetShapeToMesh();
+  GEOM::GEOM_Gen_var      geomGen = SMESH::GetGEOMGen( meshShape );
 
   QStringList entryList;
   QList<int> rows;
@@ -1281,7 +1370,7 @@ void SMESHGUI_BaseComputeOp::onPublishShape()
         // look for myMainShape in the table
         for ( int r = 0, nr = table()->rowCount(); r < nr; ++r ) {
           if ( table()->item( r, COL_SHAPEID )->text() == "1" ) {
-            if ( so->_is_nil() ) {
+            if ( !so->_is_nil() ) {
               CORBA::String_var name  = so->GetName();
               CORBA::String_var entry = so->GetID();
               QString       shapeText = QString("%1 (%2)").arg( name.in() ).arg( entry.in() );
@@ -1553,23 +1642,6 @@ void SMESHGUI_ComputeOp::startOperation()
   computeMesh();
 }
 
-//================================================================================
-/*!
- * \brief check the same operations on the same mesh
- */
-//================================================================================
-
-bool SMESHGUI_BaseComputeOp::isValid(  SUIT_Operation* theOp  ) const
-{
-  SMESHGUI_BaseComputeOp* baseOp = dynamic_cast<SMESHGUI_BaseComputeOp*>( theOp );
-  bool ret = true;
-  if ( !myMesh->_is_nil() && baseOp ) {
-    SMESH::SMESH_Mesh_var aMesh = baseOp->getMesh();
-    if ( !aMesh->_is_nil() && aMesh->GetId() == myMesh->GetId() ) ret = false;
-  }
-  return ret;
-}
-
 //================================================================================
 /*!
  * \brief Gets dialog of this operation
@@ -1957,7 +2029,6 @@ void SMESHGUI_PrecomputeOp::onPreview()
   bool computeFailed = true, memoryLack = false;
 
   SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
-  aCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
 
   SMESHGUI* gui = getSMESHGUI();
   SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
@@ -2194,7 +2265,7 @@ void SMESHGUI_BaseComputeOp::evaluateMesh()
   QString                        aHypErrors;
 
   bool evaluateFailed = true, memoryLack = false;
-  SMESH::long_array_var aRes;
+  SMESH::smIdType_array_var aRes;
 
   _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
   if ( !aMeshSObj ) //  IPAL21340
@@ -2204,7 +2275,6 @@ void SMESHGUI_BaseComputeOp::evaluateMesh()
   bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
   if ( shapeOK )
   {
-    myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
     SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
     SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
     if ( errors->length() > 0 ) {
@@ -2270,7 +2340,7 @@ void SMESHGUI_BaseComputeOp::evaluateMesh()
 }
 
 
-void SMESHGUI_BaseComputeOp::showEvaluateResult(const SMESH::long_array& theRes,
+void SMESHGUI_BaseComputeOp::showEvaluateResult(const SMESH::smIdType_array& theRes,
                                                 const bool theMemoryLack,
                                                 const bool theNoCompError,
                                                 SMESH::compute_error_array_var& theCompErrors,
@@ -2408,3 +2478,43 @@ SMESHGUI_ComputeDlg* SMESHGUI_BaseComputeOp::evaluateDlg() const
   return myCompDlg;
 }
 
+//================================================================================
+/*!
+ * \brief SMESHGUI_BaseComputeOp constructor
+ */
+//================================================================================
+
+SMESHGUI_ShowErrorsOp::SMESHGUI_ShowErrorsOp():
+  SMESHGUI_BaseComputeOp()
+{
+}
+
+//================================================================================
+/*!
+ * \brief Start SMESHGUI_ShowErrorsOp
+ */
+//================================================================================
+
+void SMESHGUI_ShowErrorsOp::startOperation()
+{
+  SMESHGUI_BaseComputeOp::startOperation();
+
+  if ( myMesh->_is_nil() )
+    return;
+
+  SMESH::SMESH_Gen_var                  gen = getSMESHGUI()->GetSMESHGen();
+  SMESH::compute_error_array_var compErrors = gen->GetComputeErrors( myMesh, myMainShape );
+  QString                        hypErrors;
+  if ( compErrors->length() == 0 )
+    return;
+
+  showComputeResult( /*MemoryLack=*/false, /*NoCompError=*/false, compErrors,
+                     /*NoHypoError=*/true, hypErrors );
+
+  SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
+  aCompDlg->setWindowTitle( tr( "SMESH_WRN_COMPUTE_FAILED" ));
+  aCompDlg->myFullInfo->hide();
+  aCompDlg->myBriefInfo->hide();
+
+  return;
+}