]> SALOME platform Git repositories - plugins/netgenplugin.git/blobdiff - src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx
Salome HOME
Copyright update 2021
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_NETGEN_2D_ONLY.cxx
index c383e5f1ddbdf6b524f34c48d7d86f1fc7e51f13..0739d65e50a99890217afd4c436c737186119b02 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -63,11 +63,7 @@ namespace nglib {
 #include <meshing.hpp>
 //#include <meshtype.hpp>
 namespace netgen {
-#ifdef NETGEN_V5
-  extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, MeshingParameters&, int, int);
-#else
-  extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
-#endif
+  NETGENPLUGIN_DLL_HEADER
   extern MeshingParameters mparam;
   extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh);
 }
@@ -83,9 +79,8 @@ using namespace nglib;
 //=============================================================================
 
 NETGENPlugin_NETGEN_2D_ONLY::NETGENPlugin_NETGEN_2D_ONLY(int        hypId,
-                                                         int        studyId,
                                                          SMESH_Gen* gen)
-  : SMESH_2D_Algo(hypId, studyId, gen)
+  : SMESH_2D_Algo(hypId, gen)
 {
   _name = "NETGEN_2D_ONLY";
   
@@ -112,7 +107,7 @@ NETGENPlugin_NETGEN_2D_ONLY::NETGENPlugin_NETGEN_2D_ONLY(int        hypId,
 
 NETGENPlugin_NETGEN_2D_ONLY::~NETGENPlugin_NETGEN_2D_ONLY()
 {
-  MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::~NETGENPlugin_NETGEN_2D_ONLY");
+  //MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::~NETGENPlugin_NETGEN_2D_ONLY");
 }
 
 //=============================================================================
@@ -167,7 +162,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh&         aMesh,
 
   int nbHyps = bool(_hypMaxElementArea) + bool(_hypLengthFromEdges) + bool(_hypParameters );
   if ( nbHyps > 1 )
-    aStatus = HYP_CONCURENT;
+    aStatus = HYP_CONCURRENT;
   else if ( hasVL )
     error( StdMeshers_ViscousLayers2D::CheckHypothesis( aMesh, aShape, aStatus ));
   else
@@ -284,22 +279,26 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
       netgen::mparam.minh = aMesher.GetDefaultMinSize( aShape, netgen::mparam.maxh );
     }
     // set local size depending on curvature and NOT closeness of EDGEs
+#ifdef NETGEN_V6
+    const double factor = *netgen::mparam.closeedgefac;
+    netgen::mparam.closeedgefac = std::nullopt;
+#else
+    const double factor = netgen::occparam.resthcloseedgefac;
     netgen::occparam.resthcloseedgeenable = false;
     //netgen::occparam.resthcloseedgefac = 1.0 + netgen::mparam.grading;
+#endif
     occgeoComm.face_maxh = netgen::mparam.maxh;
     netgen::OCCSetLocalMeshSize( occgeoComm, *ngMeshes[0] );
     occgeoComm.emap.Clear();
     occgeoComm.vmap.Clear();
 
     // set local size according to size of existing segments
-    const double factor = netgen::occparam.resthcloseedgefac;
     TopTools_IndexedMapOfShape edgeMap;
     TopExp::MapShapes( aMesh.GetShapeToMesh(), TopAbs_EDGE, edgeMap );
     for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
     {
       const TopoDS_Shape& edge = edgeMap( iE );
-      if ( SMESH_Algo::isDegenerated( TopoDS::Edge( edge ))/* ||
-           helper.IsSubShape( edge, aShape )*/)
+      if ( SMESH_Algo::isDegenerated( TopoDS::Edge( edge )))
         continue;
       SMESHDS_SubMesh* smDS = meshDS->MeshElements( edge );
       if ( !smDS ) continue;
@@ -317,6 +316,12 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
 
     // set local size defined on shapes
     aMesher.SetLocalSize( occgeoComm, *ngMeshes[0] );
+    aMesher.SetLocalSizeForChordalError( occgeoComm, *ngMeshes[0] );
+    try {
+      ngMeshes[0]->LoadLocalMeshSize( mparam.meshsizefilename );
+    } catch (NgException & ex) {
+      return error( COMPERR_BAD_PARMETERS, ex.What() );
+    }
   }
   netgen::mparam.uselocalh = toOptimize; // restore as it is used at surface optimization
 
@@ -348,7 +353,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
     // get all EDGEs of a FACE
     // ------------------------
     TSideVector wires =
-      StdMeshers_FaceSide::GetFaceWires( F, aMesh, ignoreMediumNodes, faceErr, proxyMesh );
+      StdMeshers_FaceSide::GetFaceWires( F, aMesh, ignoreMediumNodes, faceErr, &helper, proxyMesh );
     if ( faceErr && !faceErr->IsOK() )
       continue;
     int nbWires = wires.size();
@@ -453,6 +458,12 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
         bb.Increase (bb.Diam()/10);
         ngMesh->SetLocalH (bb.PMin(), bb.PMax(), mparam.grading);
         aMesher.SetLocalSize( occgeom, *ngMesh );
+        aMesher.SetLocalSizeForChordalError( occgeoComm, *ngMesh );
+        try {
+          ngMesh->LoadLocalMeshSize( mparam.meshsizefilename );
+        } catch (NgException & ex) {
+          return error( COMPERR_BAD_PARMETERS, ex.What() );
+        }
       }
 
       nodeVec.clear();
@@ -475,12 +486,8 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh&         aMesh,
       try {
         OCC_CATCH_SIGNALS;
 
-#ifdef NETGEN_V5
-        err = netgen::OCCGenerateMesh(occgeom, ngMesh, netgen::mparam, startWith, endWith);
-#else
-        char *optstr = 0;
-        err = netgen::OCCGenerateMesh(occgeom, ngMesh, startWith, endWith, optstr);
-#endif
+        err = ngLib.GenerateMesh(occgeom, startWith, endWith, ngMesh);
+
         if ( netgen::multithread.terminate )
           return false;
         if ( err )