diff --git a/CMakeLists.txt b/CMakeLists.txt index 200ac68712..a6a7f7ebb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -734,8 +734,13 @@ endif() endif() find_package(MEDFile REQUIRED) set(SMESH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/3rdParty/salomesmesh/inc) - else() - find_package(SMESH) + else(NOT FREECAD_USE_EXTERNAL_SMESH) + find_package(SMESH CONFIG REQUIRED) + include_directories(${SMESH_INCLUDE_DIR}) + link_directories(${SMESH_LIB_PATH}) + SET(EXTERNAL_SMESH_LIBS ${SMESH_LIBRARIES}) + add_definitions(-DHAVE_NETGEN) + add_definitions(-DEXTERNAL_SMESH) if(NOT SMESH_FOUND) message(ERROR "================\n" "SMESH not found.\n" diff --git a/src/Mod/Fem/App/AppFem.cpp b/src/Mod/Fem/App/AppFem.cpp index e4d7accdd3..7b33c0479c 100644 --- a/src/Mod/Fem/App/AppFem.cpp +++ b/src/Mod/Fem/App/AppFem.cpp @@ -119,7 +119,9 @@ PyMOD_INIT_FUNC(Fem) Fem::StdMeshers_SegmentAroundVertex_0DPy ::init_type(femModule); Fem::StdMeshers_SegmentLengthAroundVertexPy ::init_type(femModule); Fem::StdMeshers_StartEndLengthPy ::init_type(femModule); +#ifndef EXTERNAL_SMESH Fem::StdMeshers_TrianglePreferencePy ::init_type(femModule); +#endif Fem::StdMeshers_Hexa_3DPy ::init_type(femModule); // Add Types to module diff --git a/src/Mod/Fem/App/AppFemPy.cpp b/src/Mod/Fem/App/AppFemPy.cpp index 47554facb4..d1880b680a 100644 --- a/src/Mod/Fem/App/AppFemPy.cpp +++ b/src/Mod/Fem/App/AppFemPy.cpp @@ -50,7 +50,9 @@ #include #include #include -#include +#ifndef EXTERNAL_SMESH + #include +#endif #include #include #include diff --git a/src/Mod/Fem/App/CMakeLists.txt b/src/Mod/Fem/App/CMakeLists.txt index b69fad687f..cd4bba85ea 100644 --- a/src/Mod/Fem/App/CMakeLists.txt +++ b/src/Mod/Fem/App/CMakeLists.txt @@ -181,7 +181,7 @@ SET(Fem_SRCS add_library(Fem SHARED ${Fem_SRCS}) -target_link_libraries(Fem ${Fem_LIBS} ${VTK_LIBRARIES}) +target_link_libraries(Fem ${Fem_LIBS} ${VTK_LIBRARIES} ${EXTERNAL_SMESH_LIBS}) SET_BIN_DIR(Fem Fem /Mod/Fem) diff --git a/src/Mod/Fem/App/FemMesh.cpp b/src/Mod/Fem/App/FemMesh.cpp index c53083c5fe..1086cfc7da 100644 --- a/src/Mod/Fem/App/FemMesh.cpp +++ b/src/Mod/Fem/App/FemMesh.cpp @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +90,9 @@ using namespace Base; using namespace boost; static int StatCount = 0; +#ifdef EXTERNAL_SMESH + SMESH_Gen* FemMesh::_mesh_gen = 0; +#endif TYPESYSTEM_SOURCE(Fem::FemMesh , Base::Persistence); @@ -489,7 +493,13 @@ SMESH_Mesh* FemMesh::getSMesh() SMESH_Gen * FemMesh::getGenerator() { +#ifndef EXTERNAL_SMESH return SMESH_Gen::get(); +#else + if (! FemMesh::_mesh_gen) + FemMesh::_mesh_gen = new SMESH_Gen(); + return FemMesh::_mesh_gen; +#endif } void FemMesh::addHypothesis(const TopoDS_Shape & aSubShape, SMESH_HypothesisPtr hyp) @@ -1155,11 +1165,13 @@ void FemMesh::read(const char *FileName) // read brep-file myMesh->STLToMesh(File.filePath().c_str()); } +#ifndef EXTERNAL_SMESH else if (File.hasExtension("dat") ) { // read brep-file // vejmarie disable myMesh->DATToMesh(File.filePath().c_str()); } +#endif else if (File.hasExtension("bdf") ) { // read Nastran-file readNastran(File.filePath()); diff --git a/src/Mod/Fem/App/FemMesh.h b/src/Mod/Fem/App/FemMesh.h index dfe2a71c13..4eb17869df 100644 --- a/src/Mod/Fem/App/FemMesh.h +++ b/src/Mod/Fem/App/FemMesh.h @@ -160,6 +160,9 @@ private: SMESH_Mesh *myMesh; std::list hypoth; +#ifdef EXTERNAL_SMESH + static SMESH_Gen *_mesh_gen; +#endif }; } //namespace Part diff --git a/src/Mod/Fem/App/FemMeshPyImp.cpp b/src/Mod/Fem/App/FemMeshPyImp.cpp index 695ed53638..5c4a37e3b1 100644 --- a/src/Mod/Fem/App/FemMeshPyImp.cpp +++ b/src/Mod/Fem/App/FemMeshPyImp.cpp @@ -37,6 +37,9 @@ #include #include #include +#ifdef EXTERNAL_SMESH + #include +#endif #include #include diff --git a/src/Mod/Fem/App/FemMeshShapeNetgenObject.cpp b/src/Mod/Fem/App/FemMeshShapeNetgenObject.cpp index 95d5a0e202..4c70a7108c 100644 --- a/src/Mod/Fem/App/FemMeshShapeNetgenObject.cpp +++ b/src/Mod/Fem/App/FemMeshShapeNetgenObject.cpp @@ -34,6 +34,9 @@ #include #include +#ifdef EXTERNAL_SMESH + #include +#endif #include #include diff --git a/src/Mod/Fem/App/FemMeshShapeObject.cpp b/src/Mod/Fem/App/FemMeshShapeObject.cpp index ac0c3b6e70..df75a20026 100644 --- a/src/Mod/Fem/App/FemMeshShapeObject.cpp +++ b/src/Mod/Fem/App/FemMeshShapeObject.cpp @@ -61,7 +61,9 @@ #include #include #include -#include +#ifndef EXTERNAL_SMESH + #include +#endif #include #include #include diff --git a/src/Mod/Fem/App/FemVTKTools.cpp b/src/Mod/Fem/App/FemVTKTools.cpp index 40fa0730ee..73f615d0cd 100644 --- a/src/Mod/Fem/App/FemVTKTools.cpp +++ b/src/Mod/Fem/App/FemVTKTools.cpp @@ -53,6 +53,9 @@ #include #include #include +#ifdef EXTERNAL_SMESH + #include +#endif # include # include diff --git a/src/Mod/Fem/App/HypothesisPy.cpp b/src/Mod/Fem/App/HypothesisPy.cpp index 44babab6c0..14006a18b7 100755 --- a/src/Mod/Fem/App/HypothesisPy.cpp +++ b/src/Mod/Fem/App/HypothesisPy.cpp @@ -53,7 +53,9 @@ #include #include #include -#include +#ifndef EXTERNAL_SMESH + #include +#endif #include #include #include @@ -87,11 +89,13 @@ void SMESH_HypothesisPy::init_type(PyObject* module) SMESH_HypothesisPy::add_varargs_method("setLibName", &SMESH_HypothesisPy::setLibName, "setLibName(String)"); SMESH_HypothesisPy::add_varargs_method("getLibName", &SMESH_HypothesisPy::getLibName, "String getLibName()"); +#ifndef EXTERNAL_SMESH SMESH_HypothesisPy::add_varargs_method("setParameters", &SMESH_HypothesisPy::setParameters, "setParameters(String)"); SMESH_HypothesisPy::add_varargs_method("getParameters", &SMESH_HypothesisPy::getParameters, "String getParameters()"); SMESH_HypothesisPy::add_varargs_method("setLastParameters", &SMESH_HypothesisPy::setLastParameters, "setLastParameters(String)"); SMESH_HypothesisPy::add_varargs_method("getLastParameters", &SMESH_HypothesisPy::getLastParameters, "String getLastParameters()"); SMESH_HypothesisPy::add_varargs_method("clearParameters", &SMESH_HypothesisPy::clearParameters, "clearParameters()"); +#endif SMESH_HypothesisPy::add_varargs_method("isAuxiliary", &SMESH_HypothesisPy::isAuxiliary, "Bool isAuxiliary()"); SMESH_HypothesisPy::add_varargs_method("setParametersByMesh", &SMESH_HypothesisPy::setParametersByMesh, "setParametersByMesh(Mesh,Shape)"); Base::Interpreter().addType(SMESH_HypothesisPy::behaviors().type_object(), @@ -140,6 +144,8 @@ Py::Object SMESH_HypothesisPy::getLibName(const Py::Tuple& args) return Py::String(hypothesis()->GetLibName()); } + +#ifndef EXTERNAL_SMESH ////////////////////////////////////////////////////////// template Py::Object SMESH_HypothesisPy::setParameters(const Py::Tuple& args) { @@ -182,6 +188,7 @@ Py::Object SMESH_HypothesisPy::clearParameters(const Py::Tuple& args) hypothesis()->ClearParameters(); return Py::None(); } +#endif ////////////////////////////////////////////////////////////////////////// template Py::Object SMESH_HypothesisPy::setParametersByMesh(const Py::Tuple& args) @@ -646,6 +653,7 @@ StdMeshers_Hexa_3DPy::~StdMeshers_Hexa_3DPy() // ---------------------------------------------------------------------------- +#ifndef EXTERNAL_SMESH /////////////////////////////////////////////////////////// void StdMeshers_TrianglePreferencePy::init_type(PyObject* module) { behaviors().name("StdMeshers_TrianglePreference"); @@ -661,6 +669,7 @@ StdMeshers_TrianglePreferencePy::StdMeshers_TrianglePreferencePy(int hypId, int StdMeshers_TrianglePreferencePy::~StdMeshers_TrianglePreferencePy() { } +#endif /////////////////////////////////////////////////////////////////////////// // ---------------------------------------------------------------------------- diff --git a/src/Mod/Fem/App/HypothesisPy.h b/src/Mod/Fem/App/HypothesisPy.h index 8c1cde7e94..be0f5947bd 100755 --- a/src/Mod/Fem/App/HypothesisPy.h +++ b/src/Mod/Fem/App/HypothesisPy.h @@ -60,11 +60,13 @@ public: Py::Object repr(); Py::Object getLibName(const Py::Tuple& args); Py::Object setLibName(const Py::Tuple& args); +#ifndef EXTERNAL_SMESH Py::Object setParameters(const Py::Tuple& args); Py::Object getParameters(const Py::Tuple& args); Py::Object setLastParameters(const Py::Tuple& args); Py::Object getLastParameters(const Py::Tuple& args); Py::Object clearParameters(const Py::Tuple& args); +#endif Py::Object isAuxiliary(const Py::Tuple& args); Py::Object setParametersByMesh(const Py::Tuple& args); @@ -219,7 +221,7 @@ public: StdMeshers_Hexa_3DPy(int hypId, int studyId, SMESH_Gen* gen); ~StdMeshers_Hexa_3DPy(); }; - +#ifndef EXTERNAL_SMESH /////////////////////////////////////////////////////////////////////////////// class StdMeshers_TrianglePreferencePy : public SMESH_HypothesisPy { public: @@ -227,6 +229,7 @@ public: StdMeshers_TrianglePreferencePy(int hypId, int studyId, SMESH_Gen* gen); ~StdMeshers_TrianglePreferencePy(); }; +#endif /////////////////////////////////////////////////////////////////////////////////////////////// class StdMeshers_StartEndLengthPy : public SMESH_HypothesisPy { diff --git a/src/Mod/MeshPart/App/CMakeLists.txt b/src/Mod/MeshPart/App/CMakeLists.txt index 68ed18a50f..6c644e9ca8 100644 --- a/src/Mod/MeshPart/App/CMakeLists.txt +++ b/src/Mod/MeshPart/App/CMakeLists.txt @@ -67,7 +67,7 @@ SET(MeshPart_SRCS ) add_library(MeshPart SHARED ${MeshPart_SRCS}) -target_link_libraries(MeshPart ${MeshPart_LIBS}) +target_link_libraries(MeshPart ${MeshPart_LIBS} ${EXTERNAL_SMESH_LIBS}) fc_target_copy_resource(MeshPart diff --git a/src/Mod/MeshPart/App/Mesher.cpp b/src/Mod/MeshPart/App/Mesher.cpp index 5c181ca8bf..b488b2f70e 100644 --- a/src/Mod/MeshPart/App/Mesher.cpp +++ b/src/Mod/MeshPart/App/Mesher.cpp @@ -42,10 +42,17 @@ #endif #include #include + +#ifdef EXTERNAL_SMESH + #include + #include +#else + #include +#endif + #include #include #include -#include #include #include #include @@ -68,6 +75,11 @@ using namespace MeshPart; +#ifdef EXTERNAL_SMESH + SMESH_Gen* Mesher::_mesh_gen = 0; +#endif + + MeshingOutput::MeshingOutput() { buffer.reserve(80); @@ -311,8 +323,17 @@ Mesh::MeshObject* Mesher::createMesh() const #else std::list hypoth; +#ifndef EXTERNAL_SMESH SMESH_Gen* meshgen = SMESH_Gen::get(); +#else + if (! Mesher::_mesh_gen) + Mesher::_mesh_gen = new SMESH_Gen(); + SMESH_Gen* meshgen = Mesher::_mesh_gen; +#endif + SMESH_Mesh* mesh = meshgen->CreateMesh(0, true); + + int hyp=0; switch (method) { @@ -385,9 +406,10 @@ Mesh::MeshObject* Mesher::createMesh() const StdMeshers_Regular_1D* hyp1d = new StdMeshers_Regular_1D(hyp++,0,meshgen); hypoth.push_back(hyp1d); } - +#ifndef EXTERNAL_SMESH StdMeshers_TrianglePreference* hyp2d_1 = new StdMeshers_TrianglePreference(hyp++,0,meshgen); hypoth.push_back(hyp2d_1); +#endif StdMeshers_MEFISTO_2D* alg2d = new StdMeshers_MEFISTO_2D(hyp++,0,meshgen); hypoth.push_back(alg2d); } break; diff --git a/src/Mod/MeshPart/App/Mesher.h b/src/Mod/MeshPart/App/Mesher.h index 93d70e3d4d..c3c1822381 100644 --- a/src/Mod/MeshPart/App/Mesher.h +++ b/src/Mod/MeshPart/App/Mesher.h @@ -27,6 +27,7 @@ #include class TopoDS_Shape; +class SMESH_Gen; namespace Mesh { class MeshObject; } namespace MeshPart { @@ -152,6 +153,10 @@ private: #endif std::vector colors; struct Vertex; + +#ifdef EXTERNAL_SMESH + static SMESH_Gen *_mesh_gen; +#endif }; class MeshingOutput : public std::streambuf