Salome HOME
23321: EDF 12916 - Meshing problem
authoreap <eap@opencascade.com>
Fri, 26 Aug 2016 13:05:29 +0000 (16:05 +0300)
committereap <eap@opencascade.com>
Fri, 26 Aug 2016 13:05:29 +0000 (16:05 +0300)
  Skip tetra meshing if StdMeshers_QuadToTriaAdaptor detected a bad mesh

src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx
src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx

index 0aaf115392ba5eacc002546649a9a0b686276cc8..0a1091f00204b3b4ca41e670c9b81a80075829ea 100644 (file)
@@ -156,7 +156,8 @@ GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen)
   if (!_study->_is_nil())
     MESSAGE("_study->StudyId() = " << _study->StudyId());
   
-  _compute_canceled = false;
+  _computeCanceled = false;
+  _progressAdvance = 1e-4;
 }
 
 //=============================================================================
@@ -1649,6 +1650,14 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   std::map<const SMDS_MeshNode*,int> aNodeToGhs3dIdMap;
   std::vector<std::string> aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId;
 
+  MG_Tetra_API mgTetra( _computeCanceled, _progress );
+
+  _isLibUsed = mgTetra.IsLibrary();
+  if ( theMesh.NbQuadrangles() > 0 )
+    _progressAdvance /= 10;
+  if ( _viscousLayersHyp )
+    _progressAdvance /= 10;
+
   // proxyMesh must live till readGMFFile() as a proxy face can be used by
   // MG-Tetra for domain indication
   SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh ));
@@ -1666,8 +1675,10 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
           return false;
       }
       StdMeshers_QuadToTriaAdaptor* q2t = new StdMeshers_QuadToTriaAdaptor;
-      q2t->Compute( theMesh, expBox.Current(), proxyMesh.get() );
+      Ok = q2t->Compute( theMesh, expBox.Current(), proxyMesh.get() );
       components.push_back( SMESH_ProxyMesh::Ptr( q2t ));
+      if ( !Ok )
+        return false;
     }
     proxyMesh.reset( new SMESH_ProxyMesh( components ));
   }
@@ -1679,10 +1690,6 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
       return false;
   }
 
-  MG_Tetra_API mgTetra( _compute_canceled, _progress );
-
-  _isLibUsed = mgTetra.IsLibrary();
-
   int anInvalidEnforcedFlags = 0;
   Ok = writeGMFFile(&mgTetra,
                     aGMFFileName.ToCString(),
@@ -1745,7 +1752,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   std::cout << "MG-Tetra execution..." << std::endl;
   std::cout << cmd << std::endl;
 
-  _compute_canceled = false;
+  _computeCanceled = false;
 
   std::string errStr;
   Ok = mgTetra.Compute( cmd.ToCString(), errStr ); // run
@@ -1807,7 +1814,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   }
 
   if ( !_keepFiles ) {
-    if (! Ok && _compute_canceled )
+    if (! Ok && _computeCanceled )
       removeFile( aLogFileName );
     removeFile( aGMFFileName );
     removeFile( aRequiredVerticesFileName );
@@ -1915,20 +1922,25 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   std::map<const SMDS_MeshNode*,int> aNodeToGhs3dIdMap;
   std::vector<std::string> aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId;
 
+
+  MG_Tetra_API mgTetra( _computeCanceled, _progress );
+
+  _isLibUsed = mgTetra.IsLibrary();
+  if ( theMesh.NbQuadrangles() > 0 )
+    _progressAdvance /= 10;
+
   // proxyMesh must live till readGMFFile() as a proxy face can be used by
   // MG-Tetra for domain indication
   SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh ));
   if ( theMesh.NbQuadrangles() > 0 )
   {
     StdMeshers_QuadToTriaAdaptor* aQuad2Trias = new StdMeshers_QuadToTriaAdaptor;
-    aQuad2Trias->Compute( theMesh );
+    Ok = aQuad2Trias->Compute( theMesh );
     proxyMesh.reset( aQuad2Trias );
+    if ( !Ok )
+      return false;
   }
 
-  MG_Tetra_API mgTetra( _compute_canceled, _progress );
-
-  _isLibUsed = mgTetra.IsLibrary();
-
   int anInvalidEnforcedFlags = 0;
   Ok = writeGMFFile(&mgTetra,
                     aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(),
@@ -1960,7 +1972,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   std::cout << "MG-Tetra execution..." << std::endl;
   std::cout << cmd << std::endl;
 
-  _compute_canceled = false;
+  _computeCanceled = false;
 
   std::string errStr;
   Ok = mgTetra.Compute( cmd.ToCString(), errStr ); // run
@@ -2021,7 +2033,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
 
   if ( !_keepFiles )
   {
-    if (! Ok && _compute_canceled)
+    if (! Ok && _computeCanceled)
       removeFile( aLogFileName );
     removeFile( aGMFFileName );
     removeFile( aResultFileName );
@@ -2034,7 +2046,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
 
 void GHS3DPlugin_GHS3D::CancelCompute()
 {
-  _compute_canceled = true;
+  _computeCanceled = true;
 #ifdef WIN32
 #else
   std::string cmd = "ps xo pid,args | grep " + _genericName;
@@ -2370,7 +2382,7 @@ bool GHS3DPlugin_GHS3D::storeErrorDescription(const char*                logFile
                                               const std::string&         log,
                                               const _Ghs2smdsConvertor & toSmdsConvertor )
 {
-  if(_compute_canceled)
+  if(_computeCanceled)
     return error(SMESH_Comment("interruption initiated by user"));
 
   // read file
@@ -2929,7 +2941,7 @@ double GHS3DPlugin_GHS3D::GetProgress() const
     if ( _progress < 0.1 ) // the first message is at 10%
       me->_progress = GetProgressByTic();
     else if ( _progress < 0.98 )
-      me->_progress += 1e-4;
+      me->_progress += _progressAdvance;
     return _progress;
   }
 
index 0c5326bc905bf90b93986d48b5b6f0546c0f17b7..7d9a359338913f4baac52f05bc0ca55e69bea17e 100644 (file)
@@ -61,7 +61,7 @@ public:
                        const TopoDS_Shape& aShape);
 
   virtual void CancelCompute();
-  bool         computeCanceled() { return _compute_canceled;};
+  bool         computeCanceled() { return _computeCanceled; }
 
   virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
                         MapShapeNbElems& aResMap);
@@ -99,8 +99,8 @@ private:
   SALOMEDS::Study_var _study;
   SMESH_Gen_i*        _smeshGen_i;
 
-  volatile bool       _compute_canceled;
   bool                _isLibUsed;
+  double              _progressAdvance;
 };
 
 /*!