porting to smesh 8.3

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

porting to smesh 8.3

Post by looo »

as pyocct uses a newer smesh than freecad, and therefor if both libraries are installed in the same environment both libraries are not working properly.
So I would like to use smesh as an external library. But therefor we have to port to the newer smesh.

As I am not very comfortable with c++ I will put here some question to solve problems that come up during the porting.

What has been done so far:
- build external smesh as a conda-package https://github.com/LaughlinResearch/SMESH
- switch cmake options to use external smesh:

Code: Select all

      -D FREECAD_USE_EXTERNAL_SMESH=ON \
      -D SMESH_INCLUDE_DIR=$PREFIX/include/smesh \
- make some modification to freecad: https://github.com/looooo/FreeCAD/tree/smeah8.3
.
.
.
Last edited by looo on Tue Apr 03, 2018 9:21 am, edited 1 time in total.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Post by looo »

So first problem:

Code: Select all

~/projects/FreeCAD/src/Mod/MeshPart/App/Mesher.cpp:413:55: error: invalid use of incomplete type ‘class SMESHDS_Mesh’
     SMDS_FaceIteratorPtr aFaceIter = mesh->GetMeshDS()->facesIterator();
https://github.com/looooo/FreeCAD/blob/ ... p#L413L414
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: porting to smesh 8.3

Post by wmayer »

Look at the external smesh lib and check which header offers the class SMESHDS_Mesh. This header must then be included in Mesher.cpp
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Post by looo »

thanks, it seems to be a problem with definitions. HAVE_NETGEN wasn't set if FREECAD_USE_EXTERNAL_SMESH was enabled. Also I don't know if
BUILD_FEM_NETGEN should be enabled or not.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Post by looo »

next one:

~/projects/FreeCAD/src/Mod/Fem/App/HypothesisPy.cpp:147:5: error: ‘class SMESH_Hypothesis’ has no member named ‘SetParameters’

any ideas where SMESH_Hypothesis::SetParameters is defined?
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Post by looo »

I think I found this one, and it is not defined anymore in smesh8.3.

It seems everything is compiling now. But there is one linker problem, introduced by a workaround:

Code: Select all

CMakeFiles/Fem.dir/FemMesh.cpp.o: In function `Fem::FemMesh::getGenerator()':
FemMesh.cpp:(.text+0xe09): undefined reference to `Fem::FemMesh::_mesh_gen'
collect2: error: ld returned 1 exit status
this belongs to this workaround:
https://github.com/looooo/FreeCAD/commi ... 8736b0R491
User avatar
kkremitzki
Veteran
Posts: 2511
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Re: porting to smesh 8.3

Post by kkremitzki »

I was interested in tackling this during GSoC if I get in but I'm glad you're tackling it in advance! I can help on the "getting this into Debian" part as well as following along with your work on it.
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Post by looo »

I was interested in tackling this during GSoC if I get in but I'm glad you're tackling it in advance! I can help on the "getting this into Debian" part as well as following along with your work on it.
I guess there is way too much work for the summer anyway ;) I started this because I want to use pyocct and freecad together.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Post by looo »

I solved my last problem by defining the static member to 0 in the cpp file. So now FreeCAD compiles, but meshing a cube results in a crash:

Code: Select all

#0  /lib/x86_64-linux-gnu/libc.so.6(+0x354b0) [0x7f4858e8f4b0]
#1  0x7f47d5d926a7 in Standard_Transient::DecrementRefCounter() const from ~/env/cmake/../lib/libTKernel.so.7+0x7
#2  0x7f479c380982 in netgen::OCCGeometry::~OCCGeometry() from ~/env/cmake/../lib/./libocc.so+0xe2
#3  0x7f47c07bb40e in NETGENPlugin_Mesher::Compute() from ~/env/cmake/../lib/libNETGENPlugin.so+0x3fe
#4  0x7f47c07c7934 in NETGENPlugin_NETGEN_2D::Compute(SMESH_Mesh&, TopoDS_Shape const&) from ~/env/cmake/../lib/libNETGENPlugin.so+0xa4
#5  0x7f47c05478c3 in SMESH_subMesh::ComputeStateEngine(SMESH_subMesh::compute_event) from ~/env/cmake/../lib/libSMESH.so+0x1173
#6  0x7f47c049a225 in SMESH_Gen::Compute(SMESH_Mesh&, TopoDS_Shape const&, int, MeshDimension, std::set<int, std::less<int>, std::allocator<int> >*) from ~/env/cmake/../lib/libSMESH.so+0x6d5
#7  0x7f47c0e8fac9 in MeshPart::Mesher::createMesh() const from ~/work/Mod/MeshPart/MeshPart.so+0x1279
#8  0x7f47c0e83281 in MeshPart::Module::meshFromShape(Py::Tuple const&, Py::Dict const&) from ~/work/Mod/MeshPart/MeshPart.so+0xe81
#9  0x7f47c0e7e95b in Py::ExtensionModule<MeshPart::Module>::invoke_method_keyword(void*, Py::Tuple const&, Py::Dict const&) from ~/work/Mod/MeshPart/MeshPart.so+0x2b
Before I dive into smesh, are there any critical occt7.2.0 changes we made to smesh. Maybe the 8.3 needs to see some updates too.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Post by looo »

I have two problems right now:

- StdMeshers_TrianglePreference.hxx is missing, so a workaround has to be found. (commenting out doesn't work)
https://github.com/looooo/FreeCAD/commi ... f55fd9R391

- the other problem is quite strange. It's reported some libs are missing if I use debug-builds of smesh and netgen:

Code: Select all

Nicht definierter Verweis auf `SMESH_Mesh::AddHypothesis(TopoDS_Shape const&, int, std::string*)'
All works if I use release builds of netgen and smesh. No idea whats wrong here.
Post Reply