]> SALOME platform Git repositories - plugins/netgenplugin.git/blobdiff - src/NETGENPlugin/NETGENPlugin_Remesher_2D.cxx
Salome HOME
Prevent failure of the second compute in case of not closed 2D mesh
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_Remesher_2D.cxx
index 08f05b53ba449a955eb830edd49f9846e72c2d9b..03141b112fd2be960cd480ffcf78ca4f27f026ba 100644 (file)
@@ -43,7 +43,7 @@
 #include <occgeom.hpp>
 #include <meshing.hpp>
 #include <stlgeom.hpp>
-//#include <stltool.hxx>
+//#include <stltool.hpp>
 
 #include <boost/container/flat_set.hpp>
 
@@ -56,6 +56,10 @@ using namespace nglib;
 // #endif
 //   extern STLParameters stlparam;
 // }
+namespace nglib
+{
+  extern netgen::Array<netgen::Point<3> > readedges;
+}
 
 namespace
 {
@@ -109,7 +113,8 @@ namespace
     {
       // set bad faces into a compute error
       const char* text = "Non-manifold mesh. Only manifold mesh can be re-meshed";
-      SMESH_ComputeErrorPtr error = SMESH_ComputeError::New( COMPERR_BAD_INPUT_MESH, text );
+      SMESH_BadInputElements* error =
+        new SMESH_BadInputElements( myMeshDS, COMPERR_BAD_INPUT_MESH, text );
       SMESH::Controls::MultiConnection2D fun;
       fun.SetMesh( myMeshDS );
       SMDS_ElemIteratorPtr fIt = myMeshDS->elementsIterator( SMDSAbs_Face );
@@ -119,7 +124,7 @@ namespace
         if ( fun.GetValue( f->GetID() ) > 2 )
           error->myBadElements.push_back( f );
       }
-      theMesh.GetSubMesh( theMesh.GetShapeToMesh() )->GetComputeError() = error;
+      theMesh.GetSubMesh( theMesh.GetShapeToMesh() )->GetComputeError().reset( error );
       throw SALOME_Exception( text );
     }
 
@@ -153,12 +158,13 @@ namespace
       if ( !freeBords._coincidentGroups.empty() )
       {
         const char* text = "Can't re-meshed a mesh with coincident free edges";
-        SMESH_ComputeErrorPtr error = SMESH_ComputeError::New( COMPERR_BAD_INPUT_MESH, text );
+        SMESH_BadInputElements* error =
+          new SMESH_BadInputElements( myMeshDS, COMPERR_BAD_INPUT_MESH, text );
         for ( size_t i = 0; i < freeBords._borders.size(); ++i )
           error->myBadElements.insert( error->myBadElements.end(),
                                        freeBords._borders[i].begin(),
                                        freeBords._borders[i].end() );
-        theMesh.GetSubMesh( theMesh.GetShapeToMesh() )->GetComputeError() = error;
+        theMesh.GetSubMesh( theMesh.GetShapeToMesh() )->GetComputeError().reset( error );
         throw SALOME_Exception( text );
       }
     }
@@ -213,6 +219,8 @@ namespace
 
   void HoleFiller::AddHoleBorders( Ng_STL_Geometry * ngStlGeo )
   {
+    nglib::readedges.SetSize(0);
+
     for ( size_t i = 0; i < myHole.size(); ++i )
       for ( size_t iP = 1; iP < myHole[i].size(); ++iP )
       {
@@ -461,8 +469,8 @@ namespace
  */
 //=============================================================================
 
-NETGENPlugin_Remesher_2D::NETGENPlugin_Remesher_2D(int hypId, int studyId, SMESH_Gen* gen)
-  : SMESH_2D_Algo(hypId, studyId, gen)
+NETGENPlugin_Remesher_2D::NETGENPlugin_Remesher_2D(int hypId, SMESH_Gen* gen)
+  : SMESH_2D_Algo(hypId, gen)
 {
   _name = "NETGEN_Remesher_2D";
   _shapeType = (1 << TopAbs_FACE); // 1 bit /shape type
@@ -589,6 +597,12 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh&         theMesh,
     netgen::mparam.minh = netgen::mparam.maxh;
   }
 
+  // TODO: expose stlparam.resth* to the user
+  // netgen::stlparam.resthcloseedgeenable = 0; // Restrict H due to close edges
+  // netgen::stlparam.resthlinelengthenable = 0; // Restrict H due to line-length
+  // netgen::stlparam.resthatlasenable = 0;
+  // //netgen::stlparam.resthchartdistenable = 0;
+
   double h = netgen::mparam.maxh;
   ngMesh->SetGlobalH( h );
   ngMesh->SetMinimalH( netgen::mparam.minh );