This commit is contained in:
wmayer 2013-11-10 14:26:30 +01:00
parent b035e9cb0c
commit 66387458a7
7 changed files with 103 additions and 20 deletions

View File

@ -305,6 +305,12 @@ MARK_AS_ADVANCED(FORCE FREECAD_LIBPACK_CHECKFILE6X FREECAD_LIBPACK_CHECKFILE7X)
#IF(NOT SMESH_FOUND)
# MESSAGE("Salome SMESH was not found!")
#ENDIF(NOT SMESH_FOUND)
# -------------------------------- Netgen --------------------------------
if (FREECAD_BUILD_FEM_NETGEN)
find_package(NETGEN)
endif(FREECAD_BUILD_FEM_NETGEN)
# -------------------------------- OpenCV --------------------------------

36
cMake/FindNETGEN.cmake Normal file
View File

@ -0,0 +1,36 @@
# Try to find nglib/netgen
# Once done this will define
#
# NGLIB_INCLUDE_DIR - where the nglib include directory can be found
# NGLIB_LIBRARIES - Link this to use nglib
# NETGEN_INCLUDE_DIRS - where the netgen include directories can be found
#
# See also: http://git.salome-platform.org/gitweb/?p=NETGENPLUGIN_SRC.git;a=summary
# nglib
FIND_PATH(NGLIB_INCLUDE_DIR nglib.h /usr/include)
FIND_LIBRARY(NGLIB_LIBRARIES nglib /usr/lib /usr/local/lib)
# netgen headers
SET(NETGEN_INCLUDE_DIRS)
SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} -DNO_PARALLEL_THREADS -DOCCGEOMETRY)
SET(NETGENDATA /usr/share/netgen/libsrc)
FIND_PATH(NETGEN_DIR_csg csg.hpp PATHS ${NETGENDATA}/csg)
FIND_PATH(NETGEN_DIR_gen array.hpp PATHS ${NETGENDATA}/general)
FIND_PATH(NETGEN_DIR_geom2d geom2dmesh.hpp PATHS ${NETGENDATA}/geom2d)
FIND_PATH(NETGEN_DIR_gprim gprim.hpp PATHS ${NETGENDATA}/gprim)
FIND_PATH(NETGEN_DIR_la linalg.hpp PATHS ${NETGENDATA}/linalg)
FIND_PATH(NETGEN_DIR_mesh meshing.hpp PATHS ${NETGENDATA}/meshing)
FIND_PATH(NETGEN_DIR_occ occgeom.hpp PATHS ${NETGENDATA}/occ)
FIND_PATH(NETGEN_DIR_stlgeom stlgeom.hpp PATHS ${NETGENDATA}/stlgeom)
SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_csg})
SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_gen})
SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_geom2d})
SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_gprim})
SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_la})
SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_mesh})
SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_occ})
SET(NETGEN_INCLUDE_DIRS ${NETGEN_INCLUDE_DIRS} ${NETGEN_DIR_stlgeom})

View File

@ -15,6 +15,7 @@ include_directories(
${Boost_INCLUDE_DIRS}
${OCC_INCLUDE_DIR}
${NGLIB_INCLUDE_DIR}
${NETGEN_INCLUDE_DIRS}
src/SMDS
src/Driver
src/DriverUNV
@ -55,10 +56,18 @@ if(MSVC)
endif(FREECAD_BUILD_FEM_NETGEN)
else(MSVC)
set(SMESH_LIBS
${OCC_LIBRARIES}
${OCC_OCAF_LIBRARIES}
)
if(FREECAD_BUILD_FEM_NETGEN)
set(SMESH_LIBS
${NGLIB_LIBRARIES}
${OCC_LIBRARIES}
${OCC_OCAF_LIBRARIES}
)
else(FREECAD_BUILD_FEM_NETGEN)
set(SMESH_LIBS
${OCC_LIBRARIES}
${OCC_OCAF_LIBRARIES}
)
endif(FREECAD_BUILD_FEM_NETGEN)
endif(MSVC)
@ -442,13 +451,13 @@ ADD_LIBRARY(NETGENPlugin SHARED ${NETGENPlugin_source_files})
TARGET_LINK_LIBRARIES(NETGENPlugin SMDS SMESHDS SMESH StdMeshers ${SMESH_LIBS} )
if(MSVC)
set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "-DNETGENPLUGIN_EXPORTS -DNO_PARALLEL_THREADS -DOCCGEOMETRY")
set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "-DNETGENPLUGIN_EXPORTS -DNO_PARALLEL_THREADS -DOCCGEOMETRY -DNETGEN_V5")
set_target_properties(NETGENPlugin PROPERTIES DEBUG_OUTPUT_NAME "NETGENPlugind")
set_target_properties(NETGENPlugin PROPERTIES OUTPUT_NAME "NETGENPlugin")
set_target_properties(NETGENPlugin PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set_target_properties(NETGENPlugin PROPERTIES PREFIX "../")
elseif(MINGW)
set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "-DNETGENPLUGIN_EXPORTS -DNO_PARALLEL_THREADS -DOCCGEOMETRY")
set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "-DNETGENPLUGIN_EXPORTS -DNO_PARALLEL_THREADS -DOCCGEOMETRY -DNETGEN_V5")
set_target_properties(NETGENPlugin PROPERTIES OUTPUT_NAME "NETGENPlugin")
set_target_properties(NETGENPlugin PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set_target_properties(NETGENPlugin PROPERTIES PREFIX "")

View File

@ -62,8 +62,12 @@ namespace nglib {
#include <meshing.hpp>
//#include <ngexception.hpp>
namespace netgen {
__declspec(dllimport) extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
__declspec(dllimport) extern MeshingParameters mparam;
#ifdef NETGEN_V5
DLL_HEADER extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, MeshingParameters&, int, int);
DLL_HEADER extern MeshingParameters mparam;
#else
DLL_HEADER extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
#endif
}
using namespace std;
@ -203,7 +207,7 @@ void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry& occgeo,
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, 0.01, true);
BRepMesh_IncrementalMesh e(shape, 0.01, true);
} catch (Standard_Failure) {
}
Bnd_Box bb;
@ -580,11 +584,16 @@ bool NETGENPlugin_Mesher::Compute()
}
}
// let netgen create ngMesh and calculate element size on not meshed shapes
#ifndef NETGEN_V5
char *optstr = 0;
#endif
int startWith = netgen::MESHCONST_ANALYSE;
int endWith = netgen::MESHCONST_ANALYSE;
//err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, ngMesh,mparams, startWith, endWith);
#else
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#endif
if (err) comment << "Error in netgen::OCCGenerateMesh() at MESHCONST_ANALYSE step";
// fill ngMesh with nodes and elements of computed submeshes
@ -597,8 +606,11 @@ bool NETGENPlugin_Mesher::Compute()
if (!err)
{
startWith = endWith = netgen::MESHCONST_MESHEDGES;
//err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, ngMesh,mparams, startWith, endWith);
#else
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#endif
if (err) comment << "Error in netgen::OCCGenerateMesh() at 1D mesh generation";
}
// ---------------------
@ -633,8 +645,11 @@ bool NETGENPlugin_Mesher::Compute()
// let netgen compute 2D mesh
startWith = netgen::MESHCONST_MESHSURFACE;
endWith = _optimize ? netgen::MESHCONST_OPTSURFACE : netgen::MESHCONST_MESHSURFACE;
//err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, ngMesh,mparams, startWith, endWith);
#else
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#endif
if (err) comment << "Error in netgen::OCCGenerateMesh() at surface mesh generation";
}
// ---------------------
@ -669,13 +684,20 @@ bool NETGENPlugin_Mesher::Compute()
// ngMesh->SetMaxHDomain (maxhdom);
ngMesh->SetGlobalH (mparams.maxh);
mparams.grading = 0.4;
ngMesh->CalcLocalH(0.4);
#ifdef NETGEN_V5
ngMesh->CalcLocalH(mparams.grading);
#else
ngMesh->CalcLocalH();
#endif
}
// let netgen compute 3D mesh
startWith = netgen::MESHCONST_MESHVOLUME;
endWith = _optimize ? netgen::MESHCONST_OPTVOLUME : netgen::MESHCONST_MESHVOLUME;
//err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, ngMesh,mparams, startWith, endWith);
#else
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#endif
if (err) comment << "Error in netgen::OCCGenerateMesh()";
}
if (!err && mparams.secondorder > 0)

View File

@ -58,8 +58,12 @@ namespace nglib {
#include <meshing.hpp>
//#include <meshtype.hpp>
namespace netgen {
//__declspec(dllimport) extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
__declspec(dllimport) extern MeshingParameters mparam;
#ifdef NETGEN_V5
DLL_HEADER extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, MeshingParameters&, int, int);
#else
DLL_HEADER extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
#endif
DLL_HEADER extern MeshingParameters mparam;
}
using namespace std;
@ -373,9 +377,11 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh,
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
//err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
// jriegel: change, cause no such methode in nglib
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, ngMesh,netgen::mparam, startWith, endWith);
#else
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#endif
}
catch (Standard_Failure& ex) {
string comment = ex.DynamicType()->Name();

View File

@ -351,7 +351,9 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
Ng_Meshing_Parameters Netgen_param;
#ifdef NETGEN_V5
Netgen_param.second_order = Netgen_param2ndOrder;
#endif
Netgen_param.fineness = Netgen_paramFine;
Netgen_param.maxh = Netgen_paramSize;
@ -562,7 +564,9 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
Ng_Meshing_Parameters Netgen_param;
#ifdef NETGEN_V5
Netgen_param.second_order = Netgen_param2ndOrder;
#endif
Netgen_param.fineness = Netgen_paramFine;
Netgen_param.maxh = Netgen_paramSize;

View File

@ -46,11 +46,11 @@
#include <StdMeshers_LengthFromEdges.hxx>
#include <StdMeshers_NotConformAllowed.hxx>
#if defined(_MSC_VER)
#if defined(HAVE_NETGEN)
#include <NETGENPlugin_NETGEN_2D.hxx>
#include <NETGENPlugin_Hypothesis_2D.hxx>
#include <NETGENPlugin_SimpleHypothesis_2D.hxx>
#endif
#endif // HAVE_NETGEN
#endif // HAVE_SMESH
using namespace MeshPart;