Merge from BR_Dev_For_4_0.

This commit is contained in:
mkr 2008-03-24 11:48:15 +00:00
parent 22cc72b40c
commit 045264aff0
14 changed files with 1461 additions and 1152 deletions

View File

@ -13,6 +13,7 @@
ORIG_DIR=`pwd` ORIG_DIR=`pwd`
CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"` CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
NETGENPLUGIN_WITH_GUI="yes"
######################################################################## ########################################################################
# Test if the KERNEL_ROOT_DIR is set correctly # Test if the KERNEL_ROOT_DIR is set correctly
@ -28,12 +29,26 @@ fi
# echo "failed : KERNEL_SRC variable is not correct !" # echo "failed : KERNEL_SRC variable is not correct !"
# exit # exit
#fi #fi
for option
do
case $option in
-with-ihm | --with-ihm)
NETGENPLUGIN_WITH_GUI="yes"
break;;
-without-ihm | --without-ihm | -with-ihm=no | --with-ihm=no)
NETGENPLUGIN_WITH_GUI="no"
break;;
esac
done
######################################################################## ########################################################################
# Test if the GUI_ROOT_DIR is set correctly # Test if the GUI_ROOT_DIR is set correctly
if test ! -d "${GUI_ROOT_DIR}"; then if test ${NETGENPLUGIN_WITH_GUI} = yes; then
echo "failed : GUI_ROOT_DIR variable is not correct !" if test ! -d "${GUI_ROOT_DIR}"; then
exit echo "failed : GUI_ROOT_DIR variable is not correct !"
exit
fi
fi fi
######################################################################## ########################################################################
@ -63,24 +78,29 @@ fi
cd ${CONF_DIR} cd ${CONF_DIR}
ABS_CONF_DIR=`pwd` ABS_CONF_DIR=`pwd`
#######################################################################
# Update configure.ac script: to set NETGENPLUGIN_WITH_GUI variable
sed -e s/NETGENPLUGIN_WITH_GUI=[a-z]*/NETGENPLUGIN_WITH_GUI=${NETGENPLUGIN_WITH_GUI}/g configure.ac > configure.tmp
mv -f configure.tmp configure.ac
mkdir -p salome_adm/unix/config_files mkdir -p salome_adm/unix/config_files
cp -f ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files/* salome_adm/unix/config_files #cp -f ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files/* salome_adm/unix/config_files
cp -f ${KERNEL_ROOT_DIR}/salome_adm/unix/pythonbe.py salome_adm/unix #cp -f ${KERNEL_ROOT_DIR}/salome_adm/unix/pythonbe.py salome_adm/unix
cp -f ${KERNEL_ROOT_DIR}/salome_adm/unix/SALOMEconfig.h.in salome_adm/unix cp -f ${KERNEL_ROOT_DIR}/salome_adm/unix/SALOMEconfig.h.in salome_adm/unix
cp -f ${GUI_ROOT_DIR}/adm_local/unix/config_files/* salome_adm/unix/config_files #cp -f ${GUI_ROOT_DIR}/adm_local/unix/config_files/* salome_adm/unix/config_files
cp -f ${MED_ROOT_DIR}/adm_local/unix/config_files/* salome_adm/unix/config_files #cp -f ${MED_ROOT_DIR}/adm_local/unix/config_files/* salome_adm/unix/config_files
cp -f ${GEOM_ROOT_DIR}/adm_local/unix/config_files/* salome_adm/unix/config_files #cp -f ${GEOM_ROOT_DIR}/adm_local/unix/config_files/* salome_adm/unix/config_files
cp -f ${SMESH_ROOT_DIR}/adm_local/unix/config_files/* salome_adm/unix/config_files #cp -f ${SMESH_ROOT_DIR}/adm_local/unix/config_files/* salome_adm/unix/config_files
# remove KERNEL deprecated configure files # remove KERNEL deprecated configure files
for deprecated in ac_cc_warnings.m4 ac_cxx_partial_specialization.m4 \ #for deprecated in ac_cc_warnings.m4 ac_cxx_partial_specialization.m4 \
check_mico.m4 config.guess ltmain.sh ac_cxx_bool.m4 ltconfig ac_cxx_typename.m4 \ # check_mico.m4 config.guess ltmain.sh ac_cxx_bool.m4 ltconfig ac_cxx_typename.m4 \
check_pthreads.m4 config.sub libtool.m4 ac_cxx_mutable.m4 missing # check_pthreads.m4 config.sub libtool.m4 ac_cxx_mutable.m4 missing
do # do
rm -f salome_adm/unix/config_files/${deprecated} # rm -f salome_adm/unix/config_files/${deprecated}
done # done
# ____________________________________________________________________ # ____________________________________________________________________
@ -92,7 +112,20 @@ for deprecated in ac_cc_warnings.m4 ac_cxx_partial_specialization.m4 \
# autom4te.cache (directory) # autom4te.cache (directory)
echo "====================================================== aclocal" echo "====================================================== aclocal"
aclocal -I adm_local/unix/config_files -I salome_adm/unix/config_files || exit 1 if test ${NETGENPLUGIN_WITH_GUI} = yes; then
aclocal -I adm_local/unix/config_files \
-I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
-I ${GUI_ROOT_DIR}/adm_local/unix/config_files \
-I ${MED_ROOT_DIR}/adm_local/unix/config_files \
-I ${GEOM_ROOT_DIR}/adm_local/unix/config_files \
-I ${SMESH_ROOT_DIR}/adm_local/unix/config_files || exit 1
else
aclocal -I adm_local/unix/config_files \
-I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
-I ${MED_ROOT_DIR}/adm_local/unix/config_files \
-I ${GEOM_ROOT_DIR}/adm_local/unix/config_files \
-I ${SMESH_ROOT_DIR}/adm_local/unix/config_files || exit 1
fi
# ____________________________________________________________________ # ____________________________________________________________________
# libtoolize creates some configuration files (ltmain.sh, # libtoolize creates some configuration files (ltmain.sh,

View File

@ -17,18 +17,13 @@
# Created from configure.in.base # Created from configure.in.base
# #
AC_INIT([Salome2 Project NETGENPLUGIN module], [4.0.0], [gboulant@CS], [salome]) AC_INIT([Salome2 Project NETGENPLUGIN module], [4.1.1], [webmaster.salome@opencascade.com], [salome])
AC_CONFIG_AUX_DIR(salome_adm/unix/config_files) AC_CONFIG_AUX_DIR(salome_adm/unix/config_files)
AC_CANONICAL_HOST AC_CANONICAL_HOST
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE
PACKAGE=salome XVERSION=`echo $VERSION | awk -F. '{printf("0x%02x%02x%02x",$1,$2,$3)}'`
AC_SUBST(PACKAGE)
VERSION=4.0.0
XVERSION=0x040000
AC_SUBST(VERSION)
AC_SUBST(XVERSION) AC_SUBST(XVERSION)
# set up MODULE_NAME variable for dynamic construction of directories (resources, etc.) # set up MODULE_NAME variable for dynamic construction of directories (resources, etc.)
@ -228,37 +223,63 @@ AC_SUBST_FILE(CORBA)
corba=make_$ORB corba=make_$ORB
CORBA=adm_local/unix/$corba CORBA=adm_local/unix/$corba
echo NETGENPLUGIN_WITH_GUI=no
echo ---------------------------------------------
echo testing openGL
echo ---------------------------------------------
echo
CHECK_OPENGL AM_CONDITIONAL(NETGENPLUGIN_ENABLE_GUI, [test "${NETGENPLUGIN_WITH_GUI}" = "yes"])
echo if test "${NETGENPLUGIN_WITH_GUI}" = "yes"; then
echo --------------------------------------------- echo
echo testing QT echo ---------------------------------------------
echo --------------------------------------------- echo testing MSG2QM
echo echo ---------------------------------------------
echo
CHECK_QT CHECK_MSG2QM
echo echo
echo --------------------------------------------- echo ---------------------------------------------
echo testing MSG2QM echo testing openGL
echo --------------------------------------------- echo ---------------------------------------------
echo echo
CHECK_MSG2QM CHECK_OPENGL
echo echo
echo --------------------------------------------- echo ---------------------------------------------
echo testing VTK echo testing QT
echo --------------------------------------------- echo ---------------------------------------------
echo echo
CHECK_VTK CHECK_QT
echo
echo ---------------------------------------------
echo testing VTK
echo ---------------------------------------------
echo
CHECK_VTK
echo
echo ---------------------------------------------
echo Testing GUI
echo ---------------------------------------------
echo
CHECK_SALOME_GUI
echo
echo ---------------------------------------------
echo Testing full GUI
echo ---------------------------------------------
echo
CHECK_CORBA_IN_GUI
if test "x${CORBA_IN_GUI}" != "xyes"; then
echo "failed : For configure NETGENPLUGIN module necessary full GUI !"
exit
fi
fi
echo echo
echo --------------------------------------------- echo ---------------------------------------------
@ -284,26 +305,6 @@ echo
CHECK_HTML_GENERATORS CHECK_HTML_GENERATORS
echo
echo ---------------------------------------------
echo Testing GUI
echo ---------------------------------------------
echo
CHECK_SALOME_GUI
echo
echo ---------------------------------------------
echo Testing full GUI
echo ---------------------------------------------
echo
CHECK_CORBA_IN_GUI
if test "x${CORBA_IN_GUI}" != "xyes"; then
echo "failed : For configure NETGENPLUGIN module necessary full GUI !"
exit
fi
echo echo
echo --------------------------------------------- echo ---------------------------------------------
echo Testing Kernel echo Testing Kernel
@ -353,7 +354,12 @@ echo
#AM_CONDITIONAL( USE_GFORTRAN, [test "$F77" = "gfortran"]) #AM_CONDITIONAL( USE_GFORTRAN, [test "$F77" = "gfortran"])
echo Configure echo Configure
if test "${NETGENPLUGIN_WITH_GUI}" = "yes"; then
variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok SMesh_ok Netgen_ok" variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok SMesh_ok Netgen_ok"
fi
if test "${NETGENPLUGIN_WITH_GUI}" = "no"; then
variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok SMesh_ok Netgen_ok"
fi
for var in $variables for var in $variables
do do

View File

@ -41,19 +41,28 @@ module NETGENPlugin
}; };
/*! /*!
* NETGENPlugin_NETGEN_2D: interface of "1D-2D (Netgen)" algorithm * NETGENPlugin_NETGEN_2D: interface of "Netgen 1D-2D" algorithm
*/ */
interface NETGENPlugin_NETGEN_2D : SMESH::SMESH_2D_Algo interface NETGENPlugin_NETGEN_2D : SMESH::SMESH_2D_Algo
{ {
}; };
/*! /*!
* NETGENPlugin_NETGEN_2D3D: interface of "1D-2D-3D (Netgen)" algorithm * NETGENPlugin_NETGEN_2D3D: interface of "Netgen 1D-2D-3D" algorithm
*/ */
interface NETGENPlugin_NETGEN_2D3D : SMESH::SMESH_3D_Algo interface NETGENPlugin_NETGEN_2D3D : SMESH::SMESH_3D_Algo
{ {
}; };
/*!
* NETGENPlugin_NETGEN_2D_ONLY: interface of "Netgen 2D" algorithm,
* generating 2D elements on a geometrical face taking
* into account pre-existing nodes on face boundaries
*/
interface NETGENPlugin_NETGEN_2D_ONLY : SMESH::SMESH_2D_Algo
{
};
/*! /*!
* NETGENPlugin_Hypothesis: interface of "NETGEN parameters" hypothesis * NETGENPlugin_Hypothesis: interface of "NETGEN parameters" hypothesis
*/ */

View File

@ -24,6 +24,7 @@
label-id="Tetrahedron (Netgen)" label-id="Tetrahedron (Netgen)"
icon-id="mesh_algo_tetra.png" icon-id="mesh_algo_tetra.png"
hypos="MaxElementVolume" hypos="MaxElementVolume"
need-geom="false"
input="TRIA" input="TRIA"
dim="3"/> dim="3"/>
<algorithm type="NETGEN_2D" <algorithm type="NETGEN_2D"
@ -37,6 +38,14 @@
icon-id="mesh_algo_netgen_2d3d.png" icon-id="mesh_algo_netgen_2d3d.png"
hypos="NETGEN_Parameters" hypos="NETGEN_Parameters"
dim="3"/> dim="3"/>
<algorithm type="NETGEN_2D_ONLY"
label-id="Netgen 2D"
icon-id="mesh_algo_netgen_2d.png"
hypos="LengthFromEdges,MaxElementArea"
opt-hypos="QuadranglePreference"
input="EDGE"
output="TRIA,QUAD"
dim="2"/>
</algorithms> </algorithms>
</meshers-group> </meshers-group>

View File

@ -123,15 +123,17 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame()
myGrowthRate->setMaxValue( 10 ); myGrowthRate->setMaxValue( 10 );
myGrowthRate->setLineStep( 0.1 ); myGrowthRate->setLineStep( 0.1 );
const double VALUE_MAX = 1.0e+6;
new QLabel( tr( "NETGEN_SEG_PER_EDGE" ), GroupC1 ); new QLabel( tr( "NETGEN_SEG_PER_EDGE" ), GroupC1 );
myNbSegPerEdge = new QtxDblSpinBox( GroupC1 ); myNbSegPerEdge = new QtxDblSpinBox( GroupC1 );
myNbSegPerEdge->setMinValue( 0.2 ); myNbSegPerEdge->setMinValue( 0.2 );
myNbSegPerEdge->setMaxValue( 5.0 ); myNbSegPerEdge->setMaxValue( VALUE_MAX ); // (PAL14890) max value in native netgen gui is 5
new QLabel( tr( "NETGEN_SEG_PER_RADIUS" ), GroupC1 ); new QLabel( tr( "NETGEN_SEG_PER_RADIUS" ), GroupC1 );
myNbSegPerRadius = new QtxDblSpinBox( GroupC1 ); myNbSegPerRadius = new QtxDblSpinBox( GroupC1 );
myNbSegPerRadius->setMinValue( 0.2 ); myNbSegPerRadius->setMinValue( 0.2 );
myNbSegPerRadius->setMaxValue( 5.0 ); myNbSegPerRadius->setMaxValue( VALUE_MAX ); // (PAL14890) max value in native netgen gui is 5
if ( hypType()=="NETGEN_Parameters_2D" ) if ( hypType()=="NETGEN_Parameters_2D" )
{ {

View File

@ -27,4 +27,10 @@
include $(top_srcdir)/adm_local/unix/make_common_starter.am include $(top_srcdir)/adm_local/unix/make_common_starter.am
SUBDIRS = NETGEN NETGENPlugin GUI #SUBDIRS = NETGEN NETGENPlugin GUI
SUBDIRS = NETGEN NETGENPlugin
if NETGENPLUGIN_ENABLE_GUI
SUBDIRS += GUI
endif

View File

@ -41,6 +41,8 @@ dist_libNETGENEngine_la_SOURCES = \
NETGENPlugin_NETGEN_2D_i.cxx \ NETGENPlugin_NETGEN_2D_i.cxx \
NETGENPlugin_NETGEN_2D3D.cxx \ NETGENPlugin_NETGEN_2D3D.cxx \
NETGENPlugin_NETGEN_2D3D_i.cxx \ NETGENPlugin_NETGEN_2D3D_i.cxx \
NETGENPlugin_NETGEN_2D_ONLY.cxx \
NETGENPlugin_NETGEN_2D_ONLY_i.cxx \
NETGENPlugin_Hypothesis.cxx \ NETGENPlugin_Hypothesis.cxx \
NETGENPlugin_Hypothesis_i.cxx \ NETGENPlugin_Hypothesis_i.cxx \
NETGENPlugin_Hypothesis_2D.cxx \ NETGENPlugin_Hypothesis_2D.cxx \

View File

@ -25,11 +25,13 @@
// Project : SALOME // Project : SALOME
// $Header$ // $Header$
//============================================================================= //=============================================================================
#include "NETGENPlugin_Mesher.hxx" #include "NETGENPlugin_Mesher.hxx"
#include "NETGENPlugin_Hypothesis_2D.hxx" #include "NETGENPlugin_Hypothesis_2D.hxx"
#include <SMESH_Mesh.hxx> #include <SMESH_Mesh.hxx>
#include <SMESH_Comment.hxx> #include <SMESH_Comment.hxx>
#include <SMESH_ComputeError.hxx>
#include <SMESH_subMesh.hxx> #include <SMESH_subMesh.hxx>
#include <SMESHDS_Mesh.hxx> #include <SMESHDS_Mesh.hxx>
#include <SMDS_MeshElement.hxx> #include <SMDS_MeshElement.hxx>
@ -43,6 +45,9 @@
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <NCollection_Map.hxx> #include <NCollection_Map.hxx>
#include <OSD_Path.hxx>
#include <OSD_File.hxx>
#include <TCollection_AsciiString.hxx>
// Netgen include files // Netgen include files
namespace nglib { namespace nglib {
@ -153,6 +158,33 @@ Standard_Boolean IsEqual(const Link& aLink1, const Link& aLink2)
aLink1.n1 == aLink2.n2 && aLink1.n2 == aLink2.n1); 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 * Here we are going to use the NETGEN mesher
@ -182,21 +214,7 @@ bool NETGENPlugin_Mesher::Compute()
// ------------------------- // -------------------------
netgen::OCCGeometry occgeo; netgen::OCCGeometry occgeo;
occgeo.shape = _shape; PrepareOCCgeometry( occgeo, _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);
// ------------------------- // -------------------------
// Generate the mesh // Generate the mesh
@ -488,5 +506,25 @@ bool NETGENPlugin_Mesher::Compute()
nglib::Ng_DeleteMesh((nglib::Ng_Mesh*)ngMesh); nglib::Ng_DeleteMesh((nglib::Ng_Mesh*)ngMesh);
nglib::Ng_Exit(); nglib::Ng_Exit();
RemoveTmpFiles();
return error->IsOK(); return error->IsOK();
} }
//================================================================================
/*!
* \brief Remove "test.out" and "problemfaces" files in current directory
*/
//================================================================================
void NETGENPlugin_Mesher::RemoveTmpFiles()
{
TCollection_AsciiString str("test.out");
OSD_Path path1( str );
OSD_File file1( path1 );
file1.Remove();
str = "problemfaces";
OSD_Path path2( str );
OSD_File file2( path2 );
file2.Remove();
}

View File

@ -30,13 +30,15 @@
#define _NETGENPlugin_Mesher_HXX_ #define _NETGENPlugin_Mesher_HXX_
#include "NETGENPlugin_Defs.hxx" #include "NETGENPlugin_Defs.hxx"
#include "StdMeshers_FaceSide.hxx"
#include "SMESH_ComputeError.hxx"
class SMESH_Mesh; class SMESH_Mesh;
class SMESHDS_Mesh; class SMESHDS_Mesh;
class TopoDS_Shape; class TopoDS_Shape;
class NETGENPlugin_Hypothesis; class NETGENPlugin_Hypothesis;
namespace netgen {
class OCCGeometry;
}
/*! /*!
* \brief This class calls the NETGEN mesher of OCC geometry * \brief This class calls the NETGEN mesher of OCC geometry
@ -54,6 +56,11 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher
bool Compute(); bool Compute();
static void PrepareOCCgeometry(netgen::OCCGeometry& occgeom,
const TopoDS_Shape& shape);
static void RemoveTmpFiles();
private: private:
SMESH_Mesh* _mesh; SMESH_Mesh* _mesh;
const TopoDS_Shape& _shape; const TopoDS_Shape& _shape;

View File

@ -28,6 +28,8 @@
//============================================================================= //=============================================================================
#include "NETGENPlugin_NETGEN_3D.hxx" #include "NETGENPlugin_NETGEN_3D.hxx"
#include "NETGENPlugin_Mesher.hxx"
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMESHDS_Mesh.hxx" #include "SMESHDS_Mesh.hxx"
@ -42,6 +44,9 @@
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
#include "utilities.h" #include "utilities.h"
#include <list> #include <list>
@ -312,11 +317,17 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
Ng_Result status; Ng_Result status;
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
status = Ng_GenerateVolumeMesh(Netgen_mesh, &Netgen_param); status = Ng_GenerateVolumeMesh(Netgen_mesh, &Netgen_param);
} }
catch (Standard_Failure& exc) {
error(COMPERR_OCC_EXCEPTION, exc.GetMessageString());
status = NG_VOLUME_FAILURE;
}
catch (...) { catch (...) {
MESSAGE("An exception has been caught during the Volume Mesh Generation ..."); error("Exception in Ng_GenerateVolumeMesh()");
error(dfltErr(), "Exception in Ng_GenerateVolumeMesh()");
status = NG_VOLUME_FAILURE; status = NG_VOLUME_FAILURE;
} }
if ( GetComputeError()->IsOK() ) { if ( GetComputeError()->IsOK() ) {
@ -378,5 +389,185 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
Ng_DeleteMesh(Netgen_mesh); Ng_DeleteMesh(Netgen_mesh);
Ng_Exit(); Ng_Exit();
NETGENPlugin_Mesher::RemoveTmpFiles();
return (status == NG_OK);
}
bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
SMESH_MesherHelper* aHelper)
{
MESSAGE("NETGENPlugin_NETGEN_3D::Compute with maxElmentsize = " << _maxElementVolume);
const int invalid_ID = -1;
bool _quadraticMesh = false;
typedef map< const SMDS_MeshNode*, int> TNodeToIDMap;
TNodeToIDMap nodeToNetgenID;
list< const SMDS_MeshElement* > triangles;
SMESHDS_Mesh* MeshDS = aHelper->GetMeshDS();
SMESH_MesherHelper::MType MeshType = aHelper->IsQuadraticMesh();
if(MeshType == SMESH_MesherHelper::COMP)
return error( COMPERR_BAD_INPUT_MESH,
SMESH_Comment("Mesh with linear and quadratic elements given."));
else if (MeshType == SMESH_MesherHelper::QUADRATIC)
_quadraticMesh = true;
SMDS_FaceIteratorPtr iteratorFace = MeshDS->facesIterator();
while(iteratorFace->more())
{
// check element
const SMDS_MeshElement* elem = iteratorFace->next();
if ( !elem )
return error( COMPERR_BAD_INPUT_MESH, "Null element encounters");
bool isTraingle = ( elem->NbNodes()==3 || (_quadraticMesh && elem->NbNodes()==6 ));
if ( !isTraingle )
return error( COMPERR_BAD_INPUT_MESH,
SMESH_Comment("Not triangle element ")<<elem->GetID());
// keep a triangle
triangles.push_back( elem );
// put elem nodes to nodeToNetgenID map
SMDS_ElemIteratorPtr triangleNodesIt = elem->nodesIterator();
while ( triangleNodesIt->more() ) {
const SMDS_MeshNode * node =
static_cast<const SMDS_MeshNode *>(triangleNodesIt->next());
if(aHelper->IsMedium(node))
continue;
nodeToNetgenID.insert( make_pair( node, invalid_ID ));
}
}
// ---------------------------------
// Feed the Netgen with surface mesh
// ---------------------------------
int Netgen_NbOfNodes = 0;
int Netgen_param2ndOrder = 0;
double Netgen_paramFine = 1.;
double Netgen_paramSize = _maxElementVolume;
double Netgen_point[3];
int Netgen_triangle[3];
int Netgen_tetrahedron[4];
Ng_Init();
Ng_Mesh * Netgen_mesh = Ng_NewMesh();
// set nodes and remember thier netgen IDs
TNodeToIDMap::iterator n_id = nodeToNetgenID.begin();
for ( ; n_id != nodeToNetgenID.end(); ++n_id )
{
const SMDS_MeshNode* node = n_id->first;
Netgen_point [ 0 ] = node->X();
Netgen_point [ 1 ] = node->Y();
Netgen_point [ 2 ] = node->Z();
Ng_AddPoint(Netgen_mesh, Netgen_point);
n_id->second = ++Netgen_NbOfNodes; // set netgen ID
}
// set triangles
list< const SMDS_MeshElement* >::iterator tria = triangles.begin();
for ( ; tria != triangles.end(); ++tria)
{
int i = 0;
SMDS_ElemIteratorPtr triangleNodesIt = (*tria)->nodesIterator();
while ( triangleNodesIt->more() ) {
const SMDS_MeshNode * node =
static_cast<const SMDS_MeshNode *>(triangleNodesIt->next());
if(aHelper->IsMedium(node))
continue;
Netgen_triangle[ i ] = nodeToNetgenID[ node ];
++i;
}
Ng_AddSurfaceElement(Netgen_mesh, NG_TRIG, Netgen_triangle);
}
// -------------------------
// Generate the volume mesh
// -------------------------
Ng_Meshing_Parameters Netgen_param;
Netgen_param.secondorder = Netgen_param2ndOrder;
Netgen_param.fineness = Netgen_paramFine;
Netgen_param.maxh = Netgen_paramSize;
Ng_Result status;
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
status = Ng_GenerateVolumeMesh(Netgen_mesh, &Netgen_param);
}
catch (Standard_Failure& exc) {
error(COMPERR_OCC_EXCEPTION, exc.GetMessageString());
status = NG_VOLUME_FAILURE;
}
catch (...) {
error("Bad mesh input!!!");
status = NG_VOLUME_FAILURE;
}
if ( GetComputeError()->IsOK() ) {
error( status, "Bad mesh input!!!");
}
int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh);
int Netgen_NbOfTetra = Ng_GetNE(Netgen_mesh);
MESSAGE("End of Volume Mesh Generation. status=" << status <<
", nb new nodes: " << Netgen_NbOfNodesNew - Netgen_NbOfNodes <<
", nb tetra: " << Netgen_NbOfTetra);
// -------------------------------------------------------------------
// Feed back the SMESHDS with the generated Nodes and Volume Elements
// -------------------------------------------------------------------
bool isOK = ( Netgen_NbOfTetra > 0 );// get whatever built
if ( isOK )
{
// vector of nodes in which node index == netgen ID
vector< const SMDS_MeshNode* > nodeVec ( Netgen_NbOfNodesNew + 1 );
// insert old nodes into nodeVec
for ( n_id = nodeToNetgenID.begin(); n_id != nodeToNetgenID.end(); ++n_id ) {
nodeVec.at( n_id->second ) = n_id->first;
}
// create and insert new nodes into nodeVec
int nodeIndex = Netgen_NbOfNodes + 1;
for ( ; nodeIndex <= Netgen_NbOfNodesNew; ++nodeIndex )
{
Ng_GetPoint( Netgen_mesh, nodeIndex, Netgen_point );
SMDS_MeshNode * node = aHelper->AddNode(Netgen_point[0],
Netgen_point[1],
Netgen_point[2]);
nodeVec.at(nodeIndex) = node;
}
// create tetrahedrons
for ( int elemIndex = 1; elemIndex <= Netgen_NbOfTetra; ++elemIndex )
{
Ng_GetVolumeElement(Netgen_mesh, elemIndex, Netgen_tetrahedron);
aHelper->AddVolume (nodeVec.at( Netgen_tetrahedron[0] ),
nodeVec.at( Netgen_tetrahedron[1] ),
nodeVec.at( Netgen_tetrahedron[2] ),
nodeVec.at( Netgen_tetrahedron[3] ));
}
}
Ng_DeleteMesh(Netgen_mesh);
Ng_Exit();
NETGENPlugin_Mesher::RemoveTmpFiles();
return (status == NG_OK); return (status == NG_OK);
} }

View File

@ -49,6 +49,9 @@ public:
virtual bool Compute(SMESH_Mesh& aMesh, virtual bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape); const TopoDS_Shape& aShape);
virtual bool Compute(SMESH_Mesh& aMesh,
SMESH_MesherHelper* aHelper);
protected: protected:
double _maxElementVolume; double _maxElementVolume;

View File

@ -30,6 +30,7 @@
#include "NETGENPlugin_NETGEN_3D_i.hxx" #include "NETGENPlugin_NETGEN_3D_i.hxx"
#include "NETGENPlugin_NETGEN_2D_i.hxx" #include "NETGENPlugin_NETGEN_2D_i.hxx"
#include "NETGENPlugin_NETGEN_2D_ONLY_i.hxx"
#include "NETGENPlugin_NETGEN_2D3D_i.hxx" #include "NETGENPlugin_NETGEN_2D3D_i.hxx"
#include "NETGENPlugin_Hypothesis_i.hxx" #include "NETGENPlugin_Hypothesis_i.hxx"
#include "NETGENPlugin_Hypothesis_2D_i.hxx" #include "NETGENPlugin_Hypothesis_2D_i.hxx"
@ -62,6 +63,8 @@ extern "C"
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_3D_i>; aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_3D_i>;
else if (strcmp(aHypName, "NETGEN_2D") == 0) else if (strcmp(aHypName, "NETGEN_2D") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_2D_i>; aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_2D_i>;
else if (strcmp(aHypName, "NETGEN_2D_ONLY") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_2D_ONLY_i>;
else if (strcmp(aHypName, "NETGEN_2D3D") == 0) else if (strcmp(aHypName, "NETGEN_2D3D") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_2D3D_i>; aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_2D3D_i>;
// Hypotheses // Hypotheses