From: eap Date: Fri, 20 Jul 2007 11:26:50 +0000 (+0000) Subject: PAL15881 New NETGEN capability: is it possible to do only a 2D mesh ? X-Git-Tag: T15881~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8aa09ae9089e3cc7d12d2b98e2d6f1e61d89ed31;p=plugins%2Fnetgenplugin.git PAL15881 New NETGEN capability: is it possible to do only a 2D mesh ? + static void PrepareOCCgeometry(netgen::OCCGeometry& occgeom, + const TopoDS_Shape& shape); + static void RemoveTmpFiles(); --- diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx index 61239b3..a62fa7b 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx @@ -32,6 +32,7 @@ using namespace std; #include #include +#include #include #include #include @@ -45,6 +46,8 @@ using namespace std; #include #include #include +#include +#include // Netgen include files namespace nglib { @@ -143,6 +146,32 @@ Standard_Boolean IsEqual(const Link& aLink1, const Link& aLink2) aLink1.n1 == aLink2.n2 && aLink1.n2 == aLink2.n1); } +//================================================================================ +/*! + * \brief Initialize netgen::OCCGeometry with OCCT shape + */ +//================================================================================ + +void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry& occgeo, + const TopoDS_Shape& shape) +{ + occgeo.shape = shape; + occgeo.changed = 1; + occgeo.BuildFMap(); + BRepTools::Clean (shape); + BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, 0.01, true); + Bnd_Box bb; + BRepBndLib::Add (shape, bb); + double x1,y1,z1,x2,y2,z2; + bb.Get (x1,y1,z1,x2,y2,z2); + MESSAGE("shape bounding box:\n" << + "(" << x1 << " " << y1 << " " << z1 << ") " << + "(" << x2 << " " << y2 << " " << z2 << ")"); + netgen::Point<3> p1 = netgen::Point<3> (x1,y1,z1); + netgen::Point<3> p2 = netgen::Point<3> (x2,y2,z2); + occgeo.boundingbox = netgen::Box<3> (p1,p2); +} + //============================================================================= /*! * Here we are going to use the NETGEN mesher @@ -167,21 +196,7 @@ bool NETGENPlugin_Mesher::Compute() // ------------------------- netgen::OCCGeometry occgeo; - occgeo.shape = _shape; - occgeo.changed = 1; - occgeo.BuildFMap(); - BRepTools::Clean (_shape); - BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (_shape, 0.01, true); - Bnd_Box bb; - BRepBndLib::Add (_shape, bb); - double x1,y1,z1,x2,y2,z2; - bb.Get (x1,y1,z1,x2,y2,z2); - MESSAGE("shape bounding box:\n" << - "(" << x1 << " " << y1 << " " << z1 << ") " << - "(" << x2 << " " << y2 << " " << z2 << ")"); - netgen::Point<3> p1 = netgen::Point<3> (x1,y1,z1); - netgen::Point<3> p2 = netgen::Point<3> (x2,y2,z2); - occgeo.boundingbox = netgen::Box<3> (p1,p2); + PrepareOCCgeometry( occgeo, _shape ); // ------------------------- // Generate the mesh @@ -473,5 +488,19 @@ bool NETGENPlugin_Mesher::Compute() nglib::Ng_DeleteMesh((nglib::Ng_Mesh*)ngMesh); nglib::Ng_Exit(); + RemoveTmpFiles(); + return error->IsOK(); } + +//================================================================================ +/*! + * \brief Remove "test.out" and "problemfaces" files in current directory + */ +//================================================================================ + +void NETGENPlugin_Mesher::RemoveTmpFiles() +{ + OSD_File( OSD_Path("test.out") ).Remove(); + OSD_File( OSD_Path("problemfaces") ).Remove(); +} diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.hxx b/src/NETGENPlugin/NETGENPlugin_Mesher.hxx index 6a18639..f736e15 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.hxx @@ -29,12 +29,13 @@ #ifndef _NETGENPlugin_Mesher_HXX_ #define _NETGENPlugin_Mesher_HXX_ -#include "SMESH_ComputeError.hxx" - class SMESH_Mesh; class SMESHDS_Mesh; class TopoDS_Shape; class NETGENPlugin_Hypothesis; +namespace netgen { + class OCCGeometry; +} /*! * \brief This class calls the NETGEN mesher of OCC geometry @@ -52,6 +53,11 @@ class NETGENPlugin_Mesher bool Compute(); + static void PrepareOCCgeometry(netgen::OCCGeometry& occgeom, + const TopoDS_Shape& shape); + + static void RemoveTmpFiles(); + private: SMESH_Mesh* _mesh; const TopoDS_Shape& _shape;